cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO 4-bits mode - STM32F446RET6 Cube

MertRonom9
Associate

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:

MertRonom9_0-1719942264059.pngMertRonom9_1-1719942288837.png

SDIO global interrupt is open.

MertRonom9_2-1719942345760.png

Use DMA template is enabled.



2 REPLIES 2

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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 */

}