Table of Contents
Interfacing Micro SD cards and SD cards with the AVR microprocessor using the SPI protocol with on board ISP
Author: Robert Harrison, Daniel Richman
Date Created: August 2009
Last Revised: See Bottom of Page
Email: rharrison [email @ goes here ] hgf.com *NB The awkward email address format is to prevent my address being harvested by spammers
AVRs, and microchips in general, have very little static storage space, ~1 kilobyte, (EEPROM) when compared to the capacity of SD (Secure Digital) cards, typically 2-4 gigabytes. This guide shows how to interface an SD card and a micro SD card with the Atmel AVR series of microprocessors using the Serial Peripheral Interface (SPI) protocol. The instructions here should be applicable to other micros processors too but will require some modification. The code will obviously not work either, unless you make suitable changes for your microprocessor. One great advantage of the AVRs is the ability to program them on the target board using an In-System Programmer (ISP) connector. This ISP connector uses the same lines as SPI protocol and some steps need to be taken to isolate the ISP from the other SPI devices connected to the AVR. This guide is going to focus around the Atmega328p, a popular microchip from Atmel used in the Arduino series of boards. The code below is written and tested on the ATmega328p and may require modification to work on other micros.
Hardware & Wiring
Doing it manually
Introduction to SPI
SD Card Commands
log.c - basic write only code
Atmega328p Documentation on the ATmega328p.
Atmel's Application Notes on implementing ISP Documentation on the ATmega328p.
Secure Digital Physical Layer Simplified Specification Documentation on SD cards (See section 7 for SPI information).
Secure Digital Casrd Interface for the MSP430 Application Note from the Michigan State University.