4

I've been trying to do an SD card interface with the LPC1766 SPI peripheral for a while and right now I'm stuck in a problem that I couldn't find the answer anywhere.

The problem is: SDHC cards are not responding to write and read commands as expected.

Everything works fine on the initialization that was based on Chan's flowchart and on an NXP application note. I can differentiate the cards versions, read the OCR, CID, CSD and determine their sizes.

After that step I start writing single blocks every one second and reading it back to check the data integrity. On a Kingston SDHC 4 GB Class 4 card I can send a first write command but on the second one the card does not even answer (0x00 or 0x01) to the CMD24. With a SanDisk 4 GB Class 4 card the results are different, every command is answered by the card, but I get only zeroes when reading the data back (I'm sure I'm not writing zeroes). If I use SDSC cards, everything works fine.

I'm aware that SDHC are block addressed and not byte addressed and that I need to send ACMD41 with the CCS on for SDHC. I also know that the clock frequency is not an issue (using 400 KHz to start and then 20 MHz to write/read), because I just turned on the CRC checking and all cards are accepting the commands and data. If I stop calculating the CRC all cards reject commands and data.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Martini
  • 41
  • 2
  • 2
    Using Chan's [FatFs](http://elm-chan.org/fsw/ff/00index_e.html), I have had variable success with cards greater than 2Gb. I have always assumed that the cards that worked were SD Version 1.01 SDSC cards with 2048 byte blocks rather than v2.0 SDHC. I have never looked into it further as I did not need the higher capacity. – Clifford Jan 17 '12 at 20:21
  • I remember that I had modified Chan's code a bit, so I could initialize SanDisk cards properly without powerUps. Do you could show the SD-Card code you used? – jeb Jan 29 '12 at 14:25
  • 1
    The cause could be also the SPI driver, if you are using the FIFO's, be aware of the problem that the RX-Fifo can overflow when filling the TX-Fifo completly, as it can send effectivly 17 bytes ( my driver failed there) – jeb Sep 27 '12 at 06:43

1 Answers1

0

How do you connect your SD card? Depending on the mode/state the SD(HC) card needs an external pull-up resistor. Without that you read zero, so that may be your problem.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lukas
  • 21
  • 3