Re: PIC Micro SPI to SD Card Interface



-----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-----
.



Relevant Pages

  • Re: [PATCH] 4/5: Updates to SPI and mmc_spi: mmc_spi updated, kernel 2.6.19
    ... tarball that worked with a preliminary version of the SPI ... A given MMC transaction can ... didn't issue read-multiple commands to mmc_spi before. ... I don't know how card status changes were noticed. ...
    (Linux-Kernel)
  • PIC Micro SPI to SD Card Interface
    ... We are developing a project using PIC Microcontroller to communicate with ... SD card using SPI interface. ... SPI is initialized to 62.5 KHz ... The response from the SD card is noted by reading the SPI buffer. ...
    (comp.arch.embedded)
  • Re: SPI unterminated
    ... Dave Boland wrote: ... the plan is to run the SPI signal lines and three chip selects to ... > processor card, and some or all may have SPI devices. ... This is especially true when a clock is passed ...
    (sci.electronics.design)
  • Re: PIC Micro SPI to SD Card Interface
    ... SD card using SPI interface. ... SPI is initialized to 62.5 KHz ... The response from the SD card is noted by reading the SPI buffer. ... the host is trying to communicate in SD-SPI mode and not SD mode. ...
    (comp.arch.embedded)
  • Re: [RFC][PATCH] SPI subsystem
    ... > Can you please clarify what is 'adapter' here: ... spi adapter: A device that sits on an bus (platform, ... spi device: A SPI device which one ... two instances of a SD card adapter. ...
    (Linux-Kernel)

Loading