2015-11-16 09:52 PM
Hello,
I just wanted to let you know that the stm32cube 4.11 v1.0 generated code for MX_SDIO_SD_Init on the stm32f429 is missing the two last lines(if 1 bit mode selected 1 line is missing, if 4 bit mode selected 2 lines are missing) when outputting to mdk v5, so that you can fix it in future. void MX_SDIO_SD_Init(void) { 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 = 0; //Missing from generated code if 1 bit or 4 bit selected////////////// HAL_SD_Init(&hsd, &SDCardInfo); ///////////////////////////////////////////////////////// ///Missing from generated code if 4 bit selected HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B); ////////////////// } #stm32f429-sdio2015-11-17 12:38 AM
Hi jones.frank,
I cannot reproduce you issue, I’ am using STM32CUBMX V4.11 and STM32Cube_FW_F4_V1.9.0: The SDIO init function generated for SD 1bit selected:void
MX_SDIO_SD_Init(
void
)
{
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 = 0;
HAL_SD_Init(&hsd, &SDCardInfo);
}
The SDIO init function generated for 4 bit SD selected:
void
MX_SDIO_SD_Init(
void
)
{
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 = 0;
HAL_SD_Init(&hsd, &SDCardInfo);
HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B);
}
could you please share your .ioc file for check?
-Syrine –
2015-11-17 06:05 PM
Syrine,
I re-ran the code generator. You are correct, when you just select SDIO, it outputs the proper code. I didn't mention earlier that I also selected MiddleWares->FATFS->SD Card. When this is selected the code adds another function MX_FATFS_Init(), it would seem at some point that function would callHAL_SD_Init(&hsd, &SDCardInfo);
and
HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B)
(if 4 bit mode selected), but it does not. The cube generates does generate BSP_SD_Init(void) in bsp_driver_sd.c, which contains these two functions, but it is never called. I would presume that this is still an error, correct?
Thanks
2015-11-18 02:31 AM
Hi jones.frank,
I will check this issue with our CUBEMX team & come back to you.Sorry for the inconvenience it may bring.-Syrine-2015-11-26 02:28 AM
Dear user,
Please note that when using FATFS, the HAL_SD calls are done within the bsp_driver_sd.c file and no longer in the main.c file. Best regards