cancel
Showing results for 
Search instead for 
Did you mean: 

SDMMC HAL doesnt appear to support 4bit data for micro SDHC?

fredferd
Associate II

I use CubeMX version 5.0.0 to create the SDMMC HAL for STM32L475VTGx. In CubeMX I chose 'SD 4 bits Wide bus'. The SDMMC parameters are all defaults.

While running the initialization code inside of HAL_SD_ConfigWideBusOperation() it only allows 4bit data for CardType == CARD_SECURED, not CARD_SDHC_SDXC or CARD_SDSC. I have CARD_SDHC_SDXC (a micro SDHC 4GB card).

Also if I search for CARD_SECURED, I can't find where this CardType can be assigned. Could that be due to a bad CubeMX parameter setting?

The micro SDHC card spec shows a 4bit data bus if card is in SD bus mode. It also has a 1bit SPI bus mode.

I'm not sure what bus mode is assumed upon power up. Perhaps I need to start in 1 bit mode (assuming it boots into SPI bus mode?) and then send a command to switch to SD bus mode?

I see that CardType is used frequently in the HAL message protocol, so I want to make sure I have the correct mode to actually use the HAL, if possible.

Any help appreciated.

Thanks,

-Fred

3 REPLIES 3

Pretty sure the HAL, and examples manage this for the most part, CubeMX, who knows..

Normally you initialize the cards in 1-bit 400 KHz mode, and work the frequency and width from there. I don't recall it querying the width options, but rather switching to 4-bit based on the board level wiring.

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

So the 1 bit 400KHz mode you are suggesting is SD bus mode, I assume?

I will look through the non-cubemx examples to see how they deal with the HAL directly.

Thanks,

If you built the SDIO/SDMMC variant, then yes 1-bit SDIO mode.

Usually after it connects it reads the CSD and determines if it is an SDHC/SDHX and later gets switched to 4-bit mode

Depending on the STM32 and library version, it either passes in the 4-bit mode setting in the call to the library, or switches it after it completes. In the first case it ignores that while initially connecting at 400 KHz 1-bit.

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