2019-04-05 11:08 AM
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
2019-04-05 12:19 PM
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.
2019-04-05 01:39 PM
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,
2019-04-05 03:58 PM
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.