2
\$\begingroup\$

I am trying to make an SPI interface on a 186 Microprocessor using bit banging and a GPIO to control the CS, SCLK, MOSI and reading in the MISO lines. Mode 0. I cannot get SDHC (version2) cards to intialise to the ready state. Older SD cards work fine.

So my init sequence is as follows:

  • Plug in the SD card into a live socket
  • wait ~100ms
  • start initialization (CS, MOSI high + send 100 clock)
  • then every command has the following sequence..
    8 Clocks
    CS LOW
    8 clocks
    CMD0 (arg:0, crc:0x95) + wait R1 response
    8 more clocks
    CS High
    8 more clocks

  • Same sequence for CMD8 as follows...

(a) For the older SD cards CMD8 gives illegal
Then I send a sequence of CMD01 which initially give an 01h R1 and eventually give 00h -- indicating the card is ready.

(b) For the newer SDHC commands I get ..
CMD8 (arg:0x000001AA, crc:0x87) + wait R1 + arg echo response

Then ..

  • CMD55 (arg:0, crc:0x65) + wait response
  • CMD41 (arg:0x40000000, crc:0x77) + wait response
  • repeat ACMD41 (CMD55 + CMD41) forever.

The SDHC card never comes ready

I have tried 8GB Sandisk and Transcend SDHC cards-- the result is the same. Am I missing something here? However I suspect the clock signal....

My question is to do with the SCLK signal.
Because it is generated by bit banging, it has an uneven mark-space ratio, that dips below the 100kHz occasionally.

Has anyone successfully used an SDHC card in SPI with a slower than 100kHz clock? Or an uneven mark-space clock.

Unfortunately, it's not that easy for me to improve the clock speed with the bit banging method that I have in the code.

Thanks for any help.

\$\endgroup\$

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.