2025-04-01 8:04 AM
Hello everyone,
I create a project for the board STEVAL MKBOXPRO STM32U585. When i run it, there is an error in the initialisation of SDMMC1 with the initial generation of the function :
static void MX_SDMMC1_SD_Init(void)
{
hsd1.Instance = SDMMC1;
hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd1.Init.BusWide = SDMMC_BUS_WIDE_4B;
hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hsd1.Init.ClockDiv = 8;
if (HAL_SD_Init(&hsd1) != HAL_OK)
{
Error_Handler();
}
}
So it goes in the Error_Handler() function. I tried to debug it and i found that the error is in the function called "SDMMC_GetCmdResp1" which return SDMMC_ERROR_CMD_RSP_TIMEOUT.
I tried to find a solution on ST forum but i don't think the problem has been really solved. I see things like it can be the delay, so i tried to put some but nothing changed.
Here a part of the function SDMMC_GetCmdResp1 :
uint32_t SDMMC_GetCmdResp1(SDMMC_TypeDef *SDMMCx, uint8_t SD_CMD, uint32_t Timeout)
{
uint32_t response_r1;
uint32_t sta_reg;
/* 8 is the number of required instructions cycles for the below loop statement.
The Timeout is expressed in ms */
uint32_t count = Timeout * (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 |
SDMMC_FLAG_BUSYD0END)) == 0U) || ((sta_reg & SDMMC_FLAG_CMDACT) != 0U));
if (__SDMMC_GET_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT))
{
__SDMMC_CLEAR_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT);
return SDMMC_ERROR_CMD_RSP_TIMEOUT;
}
Also my SDMMC clock is 48MHz. Thanks for any help.
2025-04-01 9:48 AM
Hi,
did you search sdmmc on forum here ? ...read...also my comments.
Set for beginning: 1bit mode, pin speed medium + pullup ON , on all lines.
Then try again.
2025-04-02 1:00 AM
I tried your solution but i still have the same error. I put screenshots of the parameters of SDMMC1, i think i'm missing something.
And to answer to your question yes i search SDMMC on the forum, i tried solutions about the delay like i said but nothing works.
2025-04-02 3:28 AM
Ok,
next...is the interface voltage setting ok ?
from cpu: PH8 + PH10 :
+
You dont need to look at card commands , just : init..., then mount(...1); parameter 1 = mount now .
Then try to read directory...if its ok, then sd-card access looking fine.