cancel
Showing results for 
Search instead for 
Did you mean: 

STM32cubeMX SDIO HAL driver doesn't work

SSin
Associate III

Hello all,

I just start a new project with STM32CubeMX v6.3.0, STM32CubeIDE v1.7.0 & STM32F103RC. When I add the SDIO @ CubeMX, the program just freeze @ MX_SDIO_SD_Init. So I go deeper & find out in function SDMMC_GetCmdResp1, SDIO_FLAG_CTIMEOUT flag is set, causing error status. And the error handler always loop back to MX_SDIO_SD_Init. Can anyone repeat my problem?

Attached please find my project

1 REPLY 1
SSin
Associate III

Hello! Can anyone take a look in the problem?

I tried to float all the SDIO related pins (don't connect anything to PC8, PC9, PC10, PC11, PC12 & PD2) & the problem still happen. So I go deeper & find out the program goes to

MX_SDIO_SD_Init > HAL_SD_Init > HAL_SD_InitCard > SD_PowerON > SDMMC_CmdAppCommand > SDMMC_GetCmdResp1

Before running SDMMC_GetCmdResp1 (line 877 @ stm32f1xx_ll_sdmmc.c), it runs SDIO_SendCommand. And after running MODIFY_REG @ SDIO_SendCommand, SDIOx->STA will become 4 (SDIO_FLAG_CTIMEOUT flag will raise). According to my understanding, SDMMC_CmdAppCommand writes 0x477 into SDIOx->CMD register, which mean writing 0x37 via SDIO. And the timeout flag raise because there are no response. So what is the propose for writing a command and wait for response during SDIO initialization? Is the library expect that I MUST INSTALL A VALID SD CARD in order to start the program? Otherwise the MCU can only loop back & wait for SD card?