Skip to content

SD Card over SPI

February 4, 2014

debugging the olduino 2.0 prototype has been brutal.  I’m continually running in to tricky fails that take a lot of work to debug.  The latest issue is trying to work with the sd card shield.  Somehow the card fails to release miso which means the olduino can’t load code into the 1802 since it needs miso to load the shift register.  The problem could be some hardware on the olduino board, software in the avr, a faulty sd card, or some misunderstanding of the prototol (which would translate to software in the 1802).

I have definitely established that miso is being held high by the card and that if i power cycle it, miso is freed up.  At the same time, I can see that the card’s slave select pin is being driven high.  I note from http://elm-chan.org/docs/mmc/mmc_e.html that the SD card needs final clocks before it will release miso.  In the bottom trace of the picture below you see MISO(DO in the image) being released when a set of 8 clocks is delivered befor CS is taken high and another set of 8 clocks after.

SD card requires extra clocks to release MISO.

In the example code though, there are 80 clocks sent before raising /CS and none after

 

00122 void mmc_clock_and_release(void)
00123 {
00124     uint8_t i;
00125 
00126     // SD cards require at least 8 final clocks
00127     for(i=0;i<10;i++)
00128         spi_byte(0xff); 
00129 
00130     MMC_CS_PORT |= (1 << MMC_CS);   // release CS
00131 }

Not sure what’s up with that!

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: