I am really stuck in initialisation of a maxell 4gb micro sdhc card. Any advice would be helpfull.
Instead of posting the code, I will describe the steps I make in my software and the result, as I see it on my logic analyzer
1. Send 20*0xFF with CS line in 1 logic. All init sequence is with spi clock around 400khz
2. Lower CS, send CMD0
result in logic analyzer: send 0x40, 0x00, 0x00, 0x00, 0x00, 0x95, then read 0x3f, 0x01(expected result, R1-idle). All reads are with mosi=0xff
3. send CMD8
result in LA: send 0x48, 0x00, 0x00, 0x01, 0xAA, 0x87, then read 0xFF, 0x01 (R1-idle), then read another 4 bytes, 0x00, 0x00, 0x01, 0xAA
4. send CMD58
result in LA: send 0x7A, 0x00, 0x00, 0x00, 0x00, 0xFF, read 0xFF, 0x01 (R1-idle), then read another 4 bytes, 0x00, 0xFF, 0x80, 0x00
5. send CMD55+ACMD41 until idle=0
first loop, result in LA: send 0x77, 0x00, 0x00, 0x00, 0x00, 0xFF, read 0xFF, 0x01 (idle), send 0x69, 0x40, 0x00, 0x00, 0x00, 0xFF, read 0xFF, 0x01 (idle)
second loop, result in LA: 0x77, 0x00, 0x00, 0x00, 0x00, 0xFF, read 0x00 , send 0x69, 0x40, 0x00, 0x00, 0x00, 0xFF, read 0x00
Looks like the card is initialized but actually it is not. From now until the next initialization with CMD0, no matter what I send, MISO line will be always 0
6. send CMD58, then raise CS
result in LA: send 0x7A, 0x00, 0x00, 0x00, 0x00, 0xFF, read 0x00, then read another 4 bytes, 0x00, 0x00, 0x00, 0x00
7. attempt to read sector, lowed CS, send CMD17, raise CS. All this with higher clock freq., around 10mhz
result in LA: send 0x51, 0x00, 0x00, 0x00, 0x00, 0xFF, read 0x00 forever (over 50miliseconds), no 0xFE token ever received.
Any other command which should read something (OCR or other status registers) will always return 0x00.
Any illegal command inserted before step 5 will produce an R1 result with 'illegal command' set.
Any illegal command inserted after step 5 will produce an R1=0x00.
CS was tried both ways, to lower it at the beginning of init procedure and raise it at the end, or to lower it before a command then raise it immediately after. Same result.
Read sector was tried with lower clock, same result.
The card is ok, inserted in a computer it works fine, I tried with 2 cards, same model.
Power supply is 3.3v, it is noise free.
Any ideas?
Thank you.
//pisoiu