AnsweredAssumed Answered

Is there an error in VOS (voltage scaling) setting in SM32F401 sample code?

Question asked by l.d.001 on Mar 28, 2014
Hi,

In brief, sample code appears to set Scale 3 VOS setting, but datasheet tells to set Scale 2. Who is wrong?

I am running "Demonstration" project from stsw-stm32136.zip on STMF401 discovery board
I noticed that file
STM32F401-Discovery_FW_V1.0.0\Projects\Demonstration\system_stm32f4xx.c
has lines:
     /* Select regulator voltage output Scale 2 mode, System frequency up to 84 MHz */
   ...
    PWR->CR &= (uint32_t)~(PWR_CR_VOS);

In the debugger I see that after reset PWR_CR was 0x8000,
but the above line changes it to 0x4000 and it remains 0x4000
for the duration of application execution.
But STM32F401xB/C Reference manual says
Bits15:14 VOS[1:0]:
00: Reserved (Scale 3 mode selected)
01: Scale 3 mode
10: Scale 2 mode
11: Reserved (Scale 2 mode selected)

Also, STM32F401xC datasheet says
Scale 3 for fHCLK ≤ 60 MHz
Scale 2 for 60 MHz < fHCLK ≤ 84 MHz

So, after reset MCU had PWR_CR 0x8000 - Scale 2.
This is correct:MCU can run up to max speed of 84 MHz.

But that strange line
PWR->CR &= (uint32_t)~(PWR_CR_VOS);
erased PWR_CR to 0x4000 - Scale 3
which can only run up to 60 MHz,
but the same system_stm32f4xx.c configures HCLK for 84 MHz.

So, there is an error somewhere - either in the datasheet, reference manual or source code.

So, the first  question: where is the error?
Second: what is the correct setting for VOS on STMF401 at 84 MHz?
Third: what happens if the wrong VOS is selected? Will it run incorrectly? Will power consumption be bad? Will any damage happen?

Thank you

Outcomes