STMicroelectronics / stm32h7xx_hal_driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32H7 series.
BSD 3-Clause "New" or "Revised" License
86 stars 36 forks source link

SDMMC MMC HighSpeed/DDR ClockDiv too high at 52MHz #60

Open royb3 opened 2 weeks ago

royb3 commented 2 weeks ago

Describe the set-up

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.

KRASTM commented 1 week ago

Hello @royb3,

Thank you for the report.

I agree that when SDMMC peripheral at 104MHz and switching to MMC high-speed causing the MMC Clock to run at 26MHz.

But I don't know what you mean in the third point: When running the clock slightly below 52MHz, did you mean, rather to work with 104MHz, you choose a clock below 52MHz?

Could you explain or share more details, so we can confirm the issue.

With regards.

royb3 commented 1 week ago

Hi @KRASTM

When I set the sdmmc clock at 103.999 MHz, the clockdiv is correctly being set to 1, causing the MMC clock to run at 52MHz. This is the workaround I now use for getting 52MHz HighSpeed / DDR.

KRASTM commented 1 week ago

ST Internal reference: 184656