xesscorp / VHDL_Lib

Library of VHDL components that are useful in larger designs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SDHC reading never starts (SDCard.vhd)

sy2002 opened this issue · comments

On SDHC cards, the SD Card controller (SDCard.vhd) stalls in line 455:

https://github.com/xesscorp/VHDL_Lib/blob/master/SDCard.vhd#L455

What seems to happen is: SDHC cards seem to take longer to be ready for reading, so they seem not to only send one NO_TOKEN_C, but many. But as far as I got it (sorry if I am wrong, I am a beginner): Don't we need to continue sending something like 0xFF to be able to do some kind of "active waiting" (otherwise SPI won't send anything back)?

If yes, is there any easy way to do so without redoing the whole state machine? Something like replacing the "null;" command by something like this:

txCmd_v := x"FFFFFFFFFFFF";
bitCnt_v := 8; -- only send one byte, not the whole txCmd_v, as we only want to "poll"
getCmdResponse_v := true;
rtnState_v := RD_BLK; -- return when done sending the dummy command
state_v  := START_TX

The goal would be to keep the SDHC card "actively engaged", so that we finally are able to receive a START_TOKEN_C.

What I am referring to, when writing "actively engaged" or "active waiting" is also what is written here:

http://electronics.stackexchange.com/questions/13112/sd-card-read-write-problems-in-spi-mode

In SPI, you have to send data to be able to read from the client. Remember that the master always drives the clock line. The dummy data I send when reading SD cards is 0xFF, too.

In the meantime, I found this VHDL SD card controller that is capable of handling SDHC as well as SD:
https://github.com/ibm2030/SimpleSDHC

Hi @sy2002 . Have you fixed somehow the problem of reading in SDHC? Because I have the same problem and I don't know how to solve it.