SD Card SPI Init -- help, please can you share your code?

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

casainho
Contact:
Posts: 8
Joined: Mon Jan 28, 2008 1:37 pm

SD Card SPI Init -- help, please can you share your code?

Fri Jan 16, 2009 3:50 pm

Hello :-)

We, at Rockbox Player Project, need to use SD Card and we are unable to init SD Card... can someone please share the SPI initialization code and SD Card initialization code?

You can get our code at our project page: http://code.google.com/p/rockboxplayer

Thank you.
patchell
Contact:
Location: Santa Barbara, CA USA
Posts: 1
Joined: Thu Aug 09, 2007 12:08 am

Re: SD Card SPI Init -- help, please can you share your code?

Fri Jan 23, 2009 12:17 am

Believe it or not, there is a real nice open source project called ethernut that has what you need in it.

You do not have to use the NUT-OS. The two files you will want to look at are called mmcard.c and sbimmc.c. Now mind you, these are device drivers for NUT-OS, but you should be able to glean what they are doing from these files. I just used this code today to initialize a Sanddisk micro SD card...(using NUT-OS however)...it may take a little work, but it should go.

http://www.ethernut.de/en/hardware.html
-Jim
casainho
Contact:
Posts: 8
Joined: Mon Jan 28, 2008 1:37 pm

Re: SD Card SPI Init -- help, please can you share your code?

Fri Jan 23, 2009 3:18 pm

patchell wrote:Believe it or not, there is a real nice open source project called ethernut that has what you need in it.

You do not have to use the NUT-OS. The two files you will want to look at are called mmcard.c and sbimmc.c. Now mind you, these are device drivers for NUT-OS, but you should be able to glean what they are doing from these files. I just used this code today to initialize a Sanddisk micro SD card...(using NUT-OS however)...it may take a little work, but it should go.

http://www.ethernut.de/en/hardware.html
-Jim
Thank you ;)

I also found a library with SPI drivers for SD Card and I used it to initialize the card with success ;) The library is "EFSL - Embedded Filesystems Library".

And our problem were on SPI drivers, on SPI mode, we were using a wrong SPI mode. A few days ago I used an oscilloscope and saw that I were getting the 0x01 answer to the "software reset" command but I weren't reading 0x01 on SPI but a value shifted 1 bit to left... the problem was the "clock signal being without phase with data line" - sorry for my bad English to explain.

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 2 guests