Tag Archives: small footprint

This SD card logger library fits on an ATmega8

David Gironi has designed an SD card logger library – with log rotation – that neatly fits on an ATmega8 microcontroller (MCU). Precise date and time are obtained via a DS1307 chip.

“This library implements an SD card data logger that runs on [an] ATmega,” Gironi explained in a recent blog post.

“It has a small footprint, so it can be loaded on an ATmega8, leaving space for user code; [while also] supporting SD and microSD cards formatted with FAT16.”

According to Gironi, the “Petit FAT File System Module” by ChaN is used to facilitate write capabilities to the SD card.

“We had to format the card we would like to use with FAT16 and then load it with a predefined number of empty files of a know dimension,” Gironi continued.

“Once we have files on the card, we can write on those files. You can create empty files by using the python helper provided in code.”

Configuring file dimension and number is executed on the firmware side, although the file dimension cannot be greater than 2^16 bytes as a uint16_t type variable is used to store this information. Similarly, the max number of files is limited to 256, because a uint8_t variable is employed.

“Given the number of files used by the logger and every file size, we just have to record the last written position and the file number we are using to implements the log rotation,” added Gironi. “When a file is filled up with logged data, it skips to the next one, if the file is the last one, we go back to first.”

Interested in learning more? You can check out the project on David Gironi’s official page here.