cancel
Showing results for 
Search instead for 
Did you mean: 

SDHC SPI STM32 Definitive Question

lcechetmoro
Associate II
Posted on January 26, 2016 at 23:53

Hey everybody. I`ve been browsing the forum for a while trying to solve my problems with SDHC, but I can't find an answer. I have this 4gb SDHC card and it won't initialize at all! I just can't make it work. It works fine up to the CMD8, but when it comes to sending CMD55 and CMD41, the response is only a bunch of 0xFF. Has anyone developed this driver that could give me some help? I NEED to use the SPI interface.

I am using the STM32F105 and debuggin with the STM3210C-EVAL.

Thank you! :D

#stm32-sdhc-sd-card-stm3210c-eval
3 REPLIES 3
lcechetmoro
Associate II
Posted on February 01, 2016 at 11:21

Hey everybody. A new update on my code.

Here's how I initialize the SDHC:

CMD0 > CMD8 (0x1AA arg) > CMD55 > CMD41 > CMD58, according to Chan's specs (http://elm-chan.org/docs/mmc/mmc_e.html).

It does work up to the CMD8 and returns the right values (0x1AA), as I am using an SDHC card. However, the problem is that, from that point on, I am not sure it works fine. The response values are strange, though I can get 0x00 for all of them.

Then I initialize it and, since I am trying to build a code for a USB MSC project, it does recognize my drive in Windows, but cant open the mounted drive (it appears and disappears

intermittently

).

My questions are:

1) If it does recognizee that there is a drive on Windows, does it mean that the card was initialized with success?

2) If so, where is the real problem? The addressing?

Any ideas?

Thank you! :)

lcechetmoro
Associate II
Posted on February 18, 2016 at 12:33

Anyone, please?

Posted on February 18, 2016 at 21:38

Windows recognizes the MSC based on the USB descriptors, and GET CAPACITY requests. Beyond that it is going to be dependent on the READ/WRITE requests being processed correctly and consistently.

If I were trying to troubleshoot an MSC, I'd transmit diagnostic/telemetry data about the requests, success, and data CRC, so I could determine what interactions were going on. This would be after I'd evaluated that the reads of the SDHC were working properly outside of any MSC or FatFs interactions.

Unfortunately ST's SPI-SD implementation doesn't support SDHC media, which require different initialization, and different block based read/write commands. I have a workable implementation, but it's not in a releasable form.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..