CubeMX 4.22.1 and SD card FatFs problem
- October 25, 2017
- 5 replies
- 2130 views
Hi, I'm currently trying to make SD card work with FatFS on a custom made PCB with STM32F429. I create the init files with CubeMX 4.22.1 and although I set the SD interface to be 4 bits long, I find this code in the stm32f4xx_hal_sd.c
/* Default SDIO peripheral configuration for SD card initialization */
Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; Init.BusWide = SDIO_BUS_WIDE_1B; // <--- shouldn't this be SDIO_BUS_WIDE_4B ???????? Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; Init.ClockDiv = SDIO_INIT_CLK_DIV;Also, the same thing appears in MX_SDIO_SD_Init function created by CubeMX in main.c
/* SDIO init function */
static 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; // <--- shouldn't this be SDIO_BUS_WIDE_4B ???????? hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; hsd.Init.ClockDiv = 32;}
I'm asking this because HAL_SD_ConfigWideBusOperation (found in bsp_driver_sd.c) fails with error despite correcting these 2 mistakes, so I wonder if more mistakes are present that prevent SD card from initializing correctly.
I have also worked in the past with Atmel AVR and fatfs with success, so this is not the first time I have designed PCB or dealt with fatfs. Any clues?
Thanks
Costas
