I Have a 16GB Wi-Fi SD HC Card from Transcend. I try to initialize the card via SPI using an Arduino Uno, sending

CMD0, arg: 0 , CRC: 0x95


but the expected response is:


When i try the same process with an 2 GB SD (no SDHC) card, the response is:


as expected. So the initialization process itself can't be the problem.

Here you can see the Timings of the 2GB SD card analyzed with a logic analyzer: Logic Analysis 1

Here you can see the Timings of the SDHC card analyzed by a logic analyzer: Logic Analysis

The strange thing about it is, the SD card acts as expected using:

Mode 0 (CPHA=0,CPOL=0)

So the MISO value is always stable at the rising edge as i expected it to be: (Using MMC/SDC)

On the other hand, the SDHC card doesn't behave like this, and this might be the reason why the initialization process fails. The SDHC card seems to work in Mode 1 , so the MISO value is always stable at the falling edge.

Why is the SDHC card not running in mode 0, as I expect it too?

Update: I am using the sdfatlib which is waiting the required 74 clock cycles.

// must supply min of 74 clock cycles with CS high.

for (uint8_t i = 0; i < 10; i++) spiSend(0XFF);

And also the recorded behavior shows that there are more than 74 clock cycles until CS is set to low to send the init command.

Pulses: 79 ( up: 79, down: 80) enter image description here


migrated from stackoverflow.com May 28 '14 at 21:19

This question came from our site for professional and enthusiast programmers.

  • \$\begingroup\$ An SDHC Card can take up to 8 bytes (64 SPI clock cycles) before returning a response. Try Sending 0xFF for at least 8 bytes and see if the SDHC ever gives a response. \$\endgroup\$ – justing May 28 '14 at 21:50
  • \$\begingroup\$ Actually I guess it is giving a response, since it is pulling it's line down after the first byte. Hmm... \$\endgroup\$ – justing May 28 '14 at 21:52
  • \$\begingroup\$ Do you give the card enough startup cycles on the clock line? The standard is quite clear on this and larger card will often misbehave if they don't have time to initialise after power on. \$\endgroup\$ – David May 28 '14 at 22:33
  • \$\begingroup\$ My rough code which tries to follow the spec has a comment about 74 clock cycles. I don't have the standards document to hand to look it up. \$\endgroup\$ – David May 28 '14 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.