Home Uli's Page Electronics/ Microcontroller Makingthings SD-Card (SPI-Mode) with EFSL
 

 

 

 

       
     
     

Makingthings SD-Card (SPI-Mode) with EFSL E-mail

Using a SD-Card with EFSL on the Make Controller

 

Introduction

Wouldn't it be cool to have lots of space for storing long time measurement data or to be able to load/ store sound files (MP3/ AAC whatever) even if you only have a small microcontroller like the ARM7X, AVR or PIC?
If we take a look at the currently available SD-Cards with capacities of 1- 16GB it shouldn't be a problem. These cards offer two interfaces, a parallel interface and a SPI-Interface with SPI clock speeds up to 25 MHz which is most commonly used for small microcontrollers. Most microcontrollers have SPI hardware built in and this is of course the case for the ARM7 AT91SAM7X (Atmel) used in the makingthings MAKE Controller.

The SPI interface is acually pretty simple, it needs four lines:

MOSI (Master Out Slave In)
MISO (Master In Slave Out)
CLK (Clock Out from Master)

CS (Chip Select) or sometimes SS (Slave Select)

SPI is a serial protocol developed by Motorola and it operates in full duplex mode. To send data from the Master (microcontroller) to the slave (SD-Card) the master pulls the CS line low and starts generating CLK-Pulses and at the same time sets or resets the MOSI output line depending on whether to send a 1 or 0 to the Slave (MSB comes first). So one clock pulse transmits one bit to the Slave-Device.
As long as the Slave has nothing to say/ respond MISO will stay low, but as soon as the slave has read & interpreted the command it will respond (some commands take time until a response comes). But here is the thing, the master must keep sending CLK pulses because the slave needs the clock to shift out the response to the master, so if you use SPI-Hardware you have to keep sending data after you sent your command in order to read the response.

The SPI-CLK coming from the master (CPU) keeps everything going, the slave can't send you anything without the CLK from the master, keep that in mind!

Each SPI hardware has its own CLK frequency limit so if you work with a CLK frequency to high for the slave it wont respond. SD-Cards are no different, we have to start slowly (400 kHz) and then we can go to higher speeds.

Hardware

 

 

SD-Card Adapter Schematics

 

 

SD-Card Adapter Eagle 5 PCB

 

 

Assembled SD-Card Adapter

 

Downloads Hardware

PCB as PDF
Eagle 5 Project Files
Datasheet YAMAICHI SMD SD-Card Slot
Scandisk Product Manual SD-Card V1.9

 

Software

 

Downloads Software

Makingthings EFSL Library
Makingthings demo project

My Overview of AT91SAM7X SPI-Registers

 

 

 

Last Updated ( Friday, 26 June 2009 10:56 )