Use an SD or MMC card on your next AVR project
SD / MMC cards support a SPI mode. By connecting it to an AVR’s SPI port, it can be used for general storage relatively easy. Here I demo the use of an SD / MMC card as general storage for electronics projects. I am using it with a 1MHz Atmel AVR atmega8, standard 2GB microSD card with adapter sleeve, and using a PWM port as a cheap DAC for sound output. I first loaded the SD card with pre-recorded sounds at 8KHz and 8-bit unsigned linear. I then read them in real time from the SD card and write the values to the OCR so that they set the duty cycle on a PWM port. I use a simple RC low pass filter as a cheap DAC (Digital to Analog Convertor) that is output to a speaker.
|pin number||name||avr pin|
I first found GPL example code at http://www.avrrepository.com/samplecode/sd_breakout/doc/main.html. It does not support writing though . Because it is GPL, I modified it so that it supported writing as well. Here are the files modified to support writing (I haven’t had time to clean them up).