2019-10-31 04:21 AM
stm32cubeMX have bug in SDIO 4bit
i use stm32f407vg, stm32CubeMX ver 5.4.0
in use 1 bit true work but 4bit not working.
this code generate for SDIO mode: SD 1 bit
/**
* @brief SDIO Initialization Function
* @param None
* @retval None
*/
static void MX_SDIO_SD_Init(void)
{
/* USER CODE BEGIN SDIO_Init 0 */
/* USER CODE END SDIO_Init 0 */
/* USER CODE BEGIN SDIO_Init 1 */
/* USER CODE END SDIO_Init 1 */
hsd.Instance = SDIO;
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = 4;
/* USER CODE BEGIN SDIO_Init 2 */
/* USER CODE END SDIO_Init 2 */
}
and this code generate for SDIO mode: SD 4 bit Wide bus
/**
* @brief SDIO Initialization Function
* @param None
* @retval None
*/
static void MX_SDIO_SD_Init(void)
{
/* USER CODE BEGIN SDIO_Init 0 */
/* USER CODE END SDIO_Init 0 */
/* USER CODE BEGIN SDIO_Init 1 */
/* USER CODE END SDIO_Init 1 */
hsd.Instance = SDIO;
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = 4;
/* USER CODE BEGIN SDIO_Init 2 */
/* USER CODE END SDIO_Init 2 */
}
Line 20 in two code equal, And, of course, there are some bug in sub-functions in mode 4bit wide bus.
Solved! Go to Solution.
2019-10-31 07:07 AM
This was already added to the code in your case :
if (HAL_SD_Init(&hsd) != HAL_OK)
{
Error_Handler();
}
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
{
Error_Handler();
}
After discussion with the team , the SDIO shall start with 1 bit then it will be switched to be compatible with your config.
Best Regards,
Khouloud.
2019-10-31 06:12 AM
Hello @kshin.11 ,
Could you please give me more info about the part number and version of CubeMX? or share your ioc file please.
Thanks,
Khouloud
2019-10-31 06:14 AM
sorry @kshin.11 I saw those info now, I will check it.
2019-10-31 06:26 AM
Issue reproduced, it will be fixed in the next release.
Thanks @kshin.11 for your feedback.
Best Regards,
Khouloud
2019-10-31 07:07 AM
This was already added to the code in your case :
if (HAL_SD_Init(&hsd) != HAL_OK)
{
Error_Handler();
}
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
{
Error_Handler();
}
After discussion with the team , the SDIO shall start with 1 bit then it will be switched to be compatible with your config.
Best Regards,
Khouloud.
2019-11-01 10:07 AM
Thanks @Khouloud Zemmeli for the quick reply.
Ajrekom enda Allah
2020-05-13 03:36 AM
Dear Zemmeli,
i'm using cubeMX 5.4.0.
As your answer, I need to add your script to your code.
Could you show me detail where to add ?
Which function ? which file ?
Thank you very much