2024-07-02 10:49 AM - last edited on 2024-07-02 10:55 AM by Tesla DeLorean
For the project where the goal is uSD data writing I use STM32F446RET6. When I try to use SD 1bit there seems to be no error. f_mount and f_open works fine and I can write whatever I want but when I try to use 4 bit mode neither of these functions work. f_mount returns device not ready. What can I do to fix this. Here is my IOC configurations:
SDIO global interrupt is open.
Use DMA template is enabled.
2024-07-02 10:59 AM
ST has been a bit inconsistent over the years.
The bus/card needs to be brought up in a 400-KHz 1-bit mode, and then migrated to higher speeds and wider widths.
The libraries have often done this in TWO steps. And FATFS sometimes, and sometimes not, been used to do the initialization via DISKIO layer.
Get it all working in 1-bit mode, and then add code to switch the transfer mode to 4-bit as part of the overall initialization process.
2024-07-02 01:29 PM - edited 2024-07-02 03:14 PM
I found this code from other posts in the forum and I tried it on my board. But it did not working. And when I looked in the BusWide's value it still shows me that it is on the 1 Bit mode.
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 = 0; if (HAL_SD_Init(&hsd) != HAL_OK) { Error_Handler(); } if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN SDIO_Init 2 */ /* USER CODE END SDIO_Init 2 */ }