Re: PIC Micro SPI to SD Card Interface
- From: Brendan Gillatt <brendanREMOVETHIS@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 26 Mar 2008 17:59:23 +0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
skhkrishna wrote:
Hello All,
We are developing a project using PIC Microcontroller to communicate with
SD card using SPI interface. We are using 3M card slot for connecting the
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 data
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 to
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 response
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 the
respective signals are flowing correctly.
We couldn�t diagnose the problem as the pull-up resistors used for the
3M slot are working fine.
Please advice on how to rectify this problem.
Your early reply is very much appriciated
Hari
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)
iD8DBQFH6o77uv4tpb9qDZQRAh8sAJ9BZYHqNemY4s0SM5u1oQy1Wj93twCfVPBy
lk/AXoh4uKwdLhUWTbIuh+A=
=nGCU
-----END PGP SIGNATURE-----
.
- References:
- PIC Micro SPI to SD Card Interface
- From: skhkrishna
- PIC Micro SPI to SD Card Interface
- Prev by Date: Java Developer/ System Analyst---Available Imm--- Open for Relocation--- $50/hr
- Next by Date: Re: can anyone recommend me a microcontroller
- Previous by thread: Re: PIC Micro SPI to SD Card Interface
- Next by thread: TUTORIALS ON PROGRAMMING LANGUAGES
- Index(es):
Relevant Pages
|
Loading