cancel
Showing results for 
Search instead for 
Did you mean: 

STM32-F401RE About clock Setting in various system_stm32f4xx.c files

Jcorn.19
Associate II

Hello Everybody

I started using Nucleo-F401RE (MB1136 C-04) a few months ago and I am trying to understand how work the SystemInit() function and the clock setting.

As IDE, I use SystemWorkbench/AC6.

When I start a new project using HAL or LL drivers, the system_stm32f4xx.c file which is loaded uses a simple SystemInit() function which sets HSI on and uses it ; it is fairly clear.

But if I start a new project using SPL (standard peripheral lib), the system_stm32f4xx.c file which is then loaded uses a SystemInit() function which calls a SetSyssClock() function.

  • At the beginning of the SystemInit() function, the HSI is set on, OK.
  • But then in SetSyssClock() function, the HSE is also set on.
  • Then when I run/debug the prog, I see in the RCC_CR register that both HSION and HSEON are set ; so I understand no more ! Which clock is then used to drive the system, or better to feed the PLL ?

Can someone tells me where can I find basic documentation about the setting of the clock on a such board ? I read the official doc and search the internet but do not find anything very clear.

Thank you inadvance

Jack-Michel CORNIL

P.S. sorry if my english is not correct but I am french !

11 REPLIES 11

ad. 1 and 2: Keep in mind that the "|= " is not a simple assignment, but a bitwise OR. So it sets only the 0 bit without changing the others.

ad. 3 0x24003010 is the reset value of PLLCFGR register, so after this assignment the reserved bits are still at reset value.

Jcorn.19
Associate II

Oops sorry, I did not see the | operator !

OK for the reset value of PLLCFGR, but it seems me quite strange for a F401RE whose max freq is 84MHz.