Skip to main content
Explorer
March 18, 2024
Question

STM32U5 generated code voltage scaling

  • March 18, 2024
  • 1 reply
  • 1366 views

If I generate projects for the STM32U5A9 with sysclks/hclks of 4/48/90/160 Mhz.

Then HAL_PWREx_ControlVoltageScaling is always ran early on including with an argument off PWR_REGULATOR_VOLTAGE_SCALE2 for 90 MHz.

However the function HAL_PWREx_ControlVoltageScaling has a note/comment

"Before moving to voltage scaling 2, it is mandatory to ensure that the system frequency is between 50 and 100 MHz."

However I cannot identify any generated code that raises the frequency from 4Mhz before running this function?

    This topic has been closed for replies.

    1 reply

    ST Employee
    March 19, 2024

    Hello @Kevlar700

    Unfortenately I couldn't reproduce your issue,

    when choosing HCLK=4Mhz, in the generated code I get: 

     if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE4) != HAL_OK)
     {
     Error_Handler();
     }

    Which is compliant with the documentation: "Range 4 (VCORE = 0.9 V) with CPU and peripherals running at up to 25 MHz"

    when choosing HCLK=160Mhz, in the generated code I get: 

     if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
     {
     Error_Handler();
     }

     Which is compliant with the documentation: "Range 1 (VCORE = 1.2 V) with CPU and peripherals running at up to 160 MHz"

    Maybe I misunderstood the issue, could you please elaborate more or send a project that can reproduce the issue?

    Thank you!

    Kevlar700Author
    Explorer
    April 19, 2024

    Hi, sorry for the delay.

    Aside from maybe not waiting for BOOSTRDY the code seems fine. Perhaps the HAL_PWREx_ControlVoltageScaling comments deserve a small correction as they apply only to scaling down.

    from

    "Before moving to voltage scaling 2, it is mandatory to ensure that the system frequency is between 50 and 100 MHz."

    to something like

    "Before dropping to voltage scaling 2, it is mandatory to ensure that the system frequency is between 50 and 100 MHz."

    RM 10.5.4 Dynamic voltage scaling management is quite clear

    Thank you