cancel
Showing results for 
Search instead for 
Did you mean: 

stm32cube 4.11 v1.0 - stm32f429 - MX_SDIO_SD_Init missing code

prothan
Associate II
Posted on November 17, 2015 at 06:52

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-sdio
4 REPLIES 4
Nesrine M_O
Lead II
Posted on November 17, 2015 at 09:38

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 –
prothan
Associate II
Posted on November 18, 2015 at 03:05

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 call

HAL_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
Nesrine M_O
Lead II
Posted on November 18, 2015 at 11:31

Hi jones.frank,

I will check this issue with our CUBEMX team & come back to you.Sorry for the inconvenience it may bring.

-Syrine-

stm32cube-t
Senior III
Posted on November 26, 2015 at 11:28

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