This project is a small test application which implements read and write support for MMC and SD cards. It includes
The connector is soldered to the bottom side of the board. It has a simple eject button which, when a card is inserted, needs some space beyond the connector itself. As an additional feature the connector has two electrical switches to detect wether a card is inserted and wether this card is write-protected.
I used two microcontrollers during development, the Atmel ATmega8 with 8kBytes of flash, and its pin-compatible alternative, the ATmega168 with 16kBytes flash. The first one is the one I started with, but when I implemented FAT16 write support, I ran out of flash space and switched to the ATmega168.
The circuit board used to implement and test this application.
The MMC/SD card connector on the soldering side of the circuit board.
I implemented a simple command prompt which is accessible via the UART. With commands similiar to Unix you can browse different directories, read and write files, create new ones and delete them again, and browse different directories.
The following table shows some typical code sizes in bytes:
layer | code size | static RAM usage |
---|---|---|
MMC/SD (read-only) | 1002 | 0 |
MMC/SD (read-write) | 1178 | 516 |
Partition | 382 | 0 |
FAT16 (read-only) | 3414 | 0 |
FAT16 (read-write) | 6412 | 0 |
The static RAM in the read-write case is used for buffering memory card access. Without this buffer, implementation would have been much more complicated.
Please note that the numbers above do not include the C library functions used, e.g. malloc()/free() and some string functions. These will raise the numbers somewhat if they are not already used in other program parts.
When opening a partition, filesystem, file or directory, a little amount of dynamic RAM is used, as listed in the following table.
descriptor | dynamic RAM |
---|---|
partition | 15 |
filesystem | 26 |
file | 51 |
directory | 47 |
By changing the MCU* variables in the Makefile, you can use other Atmel microcontrollers or different clock speeds. You might also want to disable write support completely by changing the corresponding defines in the sd_raw_config.h and fat16_config.h files.