stm32h7xx_hal_driver icon indicating copy to clipboard operation
stm32h7xx_hal_driver copied to clipboard

SDMMC MMC HighSpeed/DDR ClockDiv too high at 52MHz

Open royb3 opened this issue 1 year ago • 3 comments
trafficstars

Describe the set-up

  • The board (either ST RPN reference or your custom board) STM32H743

Using STM32CubeIDE 1.15.0 with latest board package.

Describe the bug When running the SDMMC peripheral at 104MHz (Required for DDR), and switching the Bus speed to 52MHz DDR. The Clockdiv calculation is off by 1, causing the MMC Clock to run at 26MHz.

How To Reproduce

  1. Indicate the global behavior of your application project

  2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...) The stm32h7xx_hal_mmc.c, line 4046: Init.ClockDiv = (sdmmc_clk / (2U * MMC_HIGH_SPEED_FREQ)) + 1U;

  3. The use case that generates the problem When running the clock slightly below 52MHz, the clockdiv is set correctly, but at 52MHz precisely, it is set too high.

  4. How we can reproduce the problem As described above.

Additional context A possible fix could be to add 1 to the divider, so the 52MHz would be rounded down: Init.ClockDiv = (sdmmc_clk / (2U * MMC_HIGH_SPEED_FREQ + 1U)) + 1U; 52MHz will then get rounded down, and the clock div gets correctly set to 1.

royb3 avatar Jun 14 '24 09:06 royb3