2025-03-05 6:18 AM
Hello,
I am using a STM32H757-i eval board.
I created a project through file >> new stm32 project, selected my board, then generated code.
However, I am going into error handler when initializing the SDMMC.
My path to go to error handler :
MX_SDMMC1_SD_Init();
if (HAL_SD_Init(&hsd1) != HAL_OK)
{
Error_Handler();
}
/* Initialize the Card parameters */
if (HAL_SD_InitCard(hsd) != HAL_OK)
{
return HAL_ERROR;
}
errorstate = SD_PowerON(hsd);
if (errorstate != HAL_SD_ERROR_NONE)
{
hsd->State = HAL_SD_STATE_READY;
hsd->ErrorCode |= errorstate;
return HAL_ERROR;
}
errorstate = SDMMC_CmdGoIdleState(hsd->Instance);
/* CMD8: SEND_IF_COND: Command available only on V2.0 cards */
errorstate = SDMMC_CmdOperCond(hsd->Instance);
errorstate = SDMMC_GetCmdResp7(SDMMCx);
uint32_t SDMMC_GetCmdResp7(SDMMC_TypeDef *SDMMCx)
{
uint32_t sta_reg;
/* 8 is the number of required instructions cycles for the below loop statement.
The SDMMC_CMDTIMEOUT is expressed in ms */
uint32_t count = SDMMC_CMDTIMEOUT * (SystemCoreClock / 8U / 1000U);
do
{
if (count-- == 0U)
{
return SDMMC_ERROR_TIMEOUT;
}
sta_reg = SDMMCx->STA;
} while (((sta_reg & (SDMMC_FLAG_CCRCFAIL | SDMMC_FLAG_CMDREND | SDMMC_FLAG_CTIMEOUT)) == 0U) ||
((sta_reg & SDMMC_FLAG_CMDACT) != 0U));
if (__SDMMC_GET_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT))
{
/* Card is not SD V2.0 compliant */
__SDMMC_CLEAR_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT);
return SDMMC_ERROR_CMD_RSP_TIMEOUT;
}
So having SDMMC_ERROR_CMD_RSP_TIMEOUT as error.
I tried both of theses solutions, both didn't work :
Would you have ideas to debug it ?
Best Regards
Matteo
2025-03-05 12:03 PM
@Matteo-uC what firmware are you using? (Project Manager, Project, Mcu and Firmware Package)
I'm having a very similar issue with a U5 processor, the issues may be connected.