cancel
Showing results for 
Search instead for 
Did you mean: 

SDMMC1 get stuck in SD_SendSDStatus

PB S.1
Associate II

Hi,

I am implementing micro-sd card with STM32H573RI using SDMMC1 interface. I am using HSE clock with input frequency 25MHz and the system clock is running at 250 MHz. SDMMC1 clock mux is sourced by PLL1Q(25MHz).

All the SD card initial commands in the command line works fine until "ACMD13" sent followed by CMD55. Once the ACMD13 sent it gets me stuck in "SD_SendSDStatus" function in the place "if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXFIFOHF))" that is the place where we get the status data.

When I look into the SDMMC_STAR register RXFIFOE shows it as empty and DPSMACT is set to 1. Command path state machine works fine, but nothing is received in the Data path state machine FIFO.

The pins used for SDMMC1 are as follows

/**SDMMC1 GPIO Configuration
PC12 ------> SDMMC1_CK
PC11 ------> SDMMC1_D3
PC10 ------> SDMMC1_D2
PC9 ------> SDMMC1_D1
PB2 ------> SDMMC1_CMD
PB13 ------> SDMMC1_D0
*/

 

Please help me to troubleshoot this issue.

3 REPLIES 3
elso
Associate III

Your problem can be caused for several reasons!

- 25 MHz might be the limit for some SD cards. Which SD card are you using? (I am using a class 10 SD card configured to 96 MHz with a clock divide factor of 4. (3 did not work in my case, can be due to long wires etc. too) 

- Due to a BUG that ST haven't fixed in years apparently, you might have to init the card as shown here: By choosing 1bit wide bus in the config, to then change it to 4B using: 

HAL_SD_ConfigWideBusOperation(&hsd1, SDMMC_BUS_WIDE_4B)

 

static void MX_SDMMC1_SD_Init(void)
{
  hsd1.Instance = SDMMC1;
  hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
  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;

  if (HAL_SD_Init(&hsd1) != HAL_OK)
  {
	  Error_Handler();
  }
  if (HAL_SD_ConfigWideBusOperation(&hsd1, SDMMC_BUS_WIDE_4B) != HAL_OK)
  {
	  Error_Handler();
  }
}

 

 - Another one can be that you have not configured your FATFS "Detect_SDIO" properly:

elso_0-1699268537561.png

And then connect one of the GND pins of the SD module of the detect-pin (PA3 in my case) and the other GND pin to GND.

Hope this can help you.

Hi,

I am also using class 10 SD card. 
Tried all the methods you have mentioned and still gets stuck in the same place.

In STM32H5 there is no Detect_SDIO and there is no FATFS support as well. 

elso
Associate III

I would assume (if you want to have it in your application), you can implement FATFS using this third-party repo:
https://github.com/STMicroelectronics/stm32_mw_fatfs/tree/5042a94556d1c4477642fc6b09450725d18ab5e8

, but I don't know if it will solve your problem.