cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 generated code voltage scaling

Kevlar700
Associate III

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?

2 REPLIES 2
Sarra.S
ST Employee

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!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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