cancel
Showing results for 
Search instead for 
Did you mean: 

PLL is enabled on power on?

Dvan .8
Associate II

I'm trying to migrate my code away from Platformio, which I've previously been using, to cmake (currently using it with clion and openocd).

I've got everything working but when I run my code I run in to one problem.

For some reason the PLL is enabled at the start of the main function.

I also have this occur when creating a cubemx project and porting that straight to cmake with no custom code at all.

The registers are set to the following at the start of main.

Dvan8_0-1705517684970.png

I can bypass the actual problem which is that I can't configure pll when it's already in use.

But this should not be happening. When running a bare project in CubeIDE RCC_CR is set to 0x00008383 and this is also the case when running my actual project through platformio.

 

I just can't figure out why this is happening.

3 REPLIES 3

Typically code is supposed to exist in SystemInit() (stm32f4xx_system.c ??) to bring up the clocks and memories so the startup code can unpack and initialize things.

HAL breaks this by doing it post main()

You can remove the code in SystemInit(), or do everything properly there.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

At the start of SystemInit the pll is already turned on in the registers.

If I understand it correctly the SystemInit is the first function that is called where these registers could be set.

everything before that is loading some arrays that are defined in the linker script.

 

So how could it be that having only switched to cmake and arm-none-eabi-gcc it now enables the pll before SystemInit()?

Which STM32?

Look into the startup code, or whatever place where the interrupt vector table is. The second entry in the table is address of reset routine, that's where the processor starts executing. Look at that reset routine, what does it do before calling main().

JW