[SOLVED] SDHC Initialisation problem

Status
Not open for further replies.

pisoiu

Advanced Member level 3
Joined
Dec 31, 2002
Messages
750
Helped
43
Reputation
86
Reaction score
21
Trophy points
1,298
Location
Romania
www.lumiastudio.eu
Activity points
7,883
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
 

Small update after some more tests:
-after first loop of CMD55+ACMD41, the card is actually release control of MISO line, it is in high impedance state until next CMD0. If I put a pullup resistor, the line will stay in 1 indefinitely, regardless of the sent command. If I put a pulldown, will stay in 0 indefinitely (until CMD0).
-I tried to insert delays of up to 10ms between commands, no effect
-I tried to put more than one reset at the beginning, no effect
-I tried to put two dummy writes (0xFF) before any command, no effect.
 
Last edited:

No, I did not but that was not the problem.
I just solved it, the GND pin of the connector was not correctly soldered to the board. It was hard to notice since it is a smd connector with pins under it, not on a side.
The card was drawing gnd through protection diodes on pins, since some of signal lines were 0, therefore allowing the card to respond to first commands. But when the initialization command was sent, I suspect the current request was higher and there was a voltage jump on the unconnected card ground line, therefore resetting the card.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…