2024-03-12 06:50 AM
Hi,
I have configured the Nucleo-L476RG to write to a 64GB exFat Micro SD Card in 4-bit mode using DMA.
This appears to work correctly once I navigate around the still present library errors which prevent you from initialising in SDMMC 4-bit mode. You must initialise in 1-bit mode and then change to 4-bit mode as described in https://community.st.com/t5/stm32cubemx-mcus/sdio-interface-not-working-in-4bits-with-stm32f4-firmware/td-p/591776.
My issue is that when I scope the data lines D0, D1, D2 and D3 the only line which toggles is D0. The timing between 1-bit and 4-bit mode has also been raised in https://community.st.com/t5/stm32-mcus-products/sd-card-read-write-mode-speed-same-in-sd-1-bit-mode-and-sd-4-bit/td-p/313236 which suggests the micro may be operating with only one data line.
I have tried various SDMMC1 clock speeds and SDMMCCLK Clock divide factors and nothing seems to make a difference. I have also enabled internal pull ups on the micro. I am using an external SD shield http://www.cqrobot.wiki/index.php/Micro_SD(TF)_Storage_Board.
The data has been written to the SD card correctly because I have checked it but I'm not sure that the board is actually operating in 4-bit mode as it should be as illustrated below.
I have checked SDMMC_CLKCR in debug mode and WIDBUS is set to 01 which is 4-wide bus mode.
Could I get some guidance on this please?
For those struggling the following link is useful:
https://github.com/dtiziano/stm32_uSD_SDIO4bit/tree/main
Extract of the setup code I have been using below:
/* USER CODE END SDMMC1_Init 1 */
hsd1.Instance = SDMMC1;
hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B;
hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hsd1.Init.ClockDiv = 4;
/* USER CODE BEGIN SDMMC1_Init 2 */
if (HAL_SD_Init(&hsd1) != HAL_OK)
{
Error_Handler();
}
if (HAL_SD_ConfigWideBusOperation(&hsd1, SDMMC_BUS_WIDE_4B) != HAL_OK)
{
Error_Handler();
}
/* USER CODE END SDMMC1_Init 2 */