- PIC Micro SPI to SD Card Interface
- Posted by skhkrishna on March 25th, 2008
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
- Posted by dk on March 26th, 2008
On Mar 26, 4:58 am, "skhkrishna" <hari.kris...@hcl.in> wrote:
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
- Posted by FreeRTOS.org on March 26th, 2008
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.
- Posted by Brendan Gillatt on March 26th, 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
skhkrishna wrote:
The critical thing with the SPI -> SD interface is that you _MUST_ send
0xFF out on the SPI data line when clocking data back from the SD card.
This is not what the C18 libraries do, so you have to write your own
spi_get ( ); routine.
It's subtle and I missed it for nearly two weeks before realising it.
The fact that you are getting 0xFF back may also mean either the SPI
module is set up to invert the data coming in or that there is an
electrical problem.
- --
Brendan Gillatt | GPG Key: 0xBF6A0D94
brendan {a} brendangillatt (dot) co (dot) uk
http://www.brendangillatt.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
iD8DBQFH6o77uv4tpb9qDZQRAh8sAJ9BZYHqNemY4s0SM5u1oQ y1Wj93twCfVPBy
lk/AXoh4uKwdLhUWTbIuh+A=
=nGCU
-----END PGP SIGNATURE-----