PIC Micro SPI to SD Card Interface

Mar 25, 2008 3 Replies

Hello All, We are developing a project using PIC Microcontroller to communicate wit SD card using SPI interface. We are using 3M card slot for connecting th microcontroller to the SD card.



In the initialization of SD card we are doing the following steps. SPI is initialized to 62.5 KHz The SD card is provided with some dummy clocks by sending some dat through the SPI The SD card is selected by lowering its CS pin The Following sequence is given through SPI for setting the SD card t IDLE state



0x40
0x00
0x00
0x00
0x00
0x95 Then few dummy clock signals are provided through SPI send The response from the SD card is noted by reading the SPI buffer. With reference to the Sandisk Product manual it is given that the respons should be of r1 format (ie, a 1 byte data with 0 at the MSB)

But we are getting the response as 0xFF for any number of clock pulses The response is similar for both the Card is in the slot or not.



While analyzing the waveforms of the SPI lines it is observed that th respective signals are flowing correctly.



We couldn?t diagnose the problem as the pull-up resistors used for th



3M slot are working fine.

Please advice on how to rectify this problem.



Your early reply is very much appriciated Hari


I am not sure if it makes sense but the SD card should understand that the host is trying to communicate in SD-SPI mode and not SD mode. I would suggest you to look into SD protocol datasheets so as to move the SD card state to SD-SPI mode and not to SD mode.

Cheers!!

-dK

As far as I know, Microchip provide an SD card interface and FAT file system free of charge for use on their micros. Have you looked at using that?

Regards, Richard. + http://www.FreeRTOS.org & http://www.FreeRTOS.org/shop 17 official architecture ports, more than 5000 downloads per month. + http://www.SafeRTOS.com Certified by TÜV as meeting the requirements for safety related systems.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required