MMC/SD/SDHC AVR Interface using ATMega8 microcontroller
MMC/SD/SDHC card library
This project provides a general purpose library which implements read and write support for MMC, SD and SDHC memory cards.
- low-level MMC, SD and SDHC read/write routines
- partition table support
- a simple FAT16/FAT32 read/write implementation
The circuit which was mainly used during development consists of an Atmel AVR microcontroller with some passive components. It is quite simple and provides an easy test environment. The circuit which can be downloaded here has been improved with regard to operation stability.
I used different microcontrollers during development, the 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. For FAT32, an ATmega328 is required.
The circuit board is a self-made and self-soldered board consisting of a single copper layer and standard DIL components, except of the MMC/SD card connector.
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 behind 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.
The software is written in C (ISO C99). It might not be the smallest or the fastest one, but I think it is quite flexible. See the benchmark page to get an idea of the possible data rates.
I implemented an example application providing a simple command prompt which is accessible via the UART at 9600 Baud. With commands similiar to the Unix shell you can browse different directories, read and write files, create new ones and delete them again. Not all commands are available in all software configurations.
- cat <file>
Writes a hexdump of <file> to the terminal.
- cd <directory>
Changes current working directory to <directory>.
Shows card manufacturer, status, filesystem capacity and free storage space.
Reinitializes and reopens the memory card.
Shows the content of the current directory.
- mkdir <directory>
Creates a directory called <directory>.
- rm <file>
Ensures all buffered data is written to the card.
- touch <file>
- write <file> <offset>
Writes text to <file>, starting from <offset>. The text is read from the UART, line by line. Finish with an empty line.
For more detail: MMC/SD/SDHC AVR Interface using ATMega8 microcontroller
Leave a Comment
You must be logged in to post a comment.