cancel
Showing results for 
Search instead for 
Did you mean: 

Re-Configure System Clock

alfaez
Associate II
Posted on July 31, 2011 at 08:38

Dear all,

I have 2 applications in my STM32 microcontroller; the Boot Loader & the Main Application. It starts with the bootloader perform some actions and then it (Jumps) to a known address to execute the main application.

The problem I've have is that system clock in boot loader differs from that in the main application. and  when it jumps to the main application, it is executed successfully but alaways with the boot loader's clock; eventhough, I reconfigure it in the main application.

My question is, how do I re-configure the system clock when I jump to the main application?

Thanks in advance,

Celo

3 REPLIES 3
Posted on July 31, 2011 at 14:30

You need to make the clock setting code smarter so that it determines the current conditions and acts accordingly.

For example :

Don't assume specific conditions, reset or otherwise.

Don't turn on HSE if it is already running.

Don't select a clock that isn't running.

Turn on HSI if it has been turned off.

If you are running from the PLL, you must switch to a different clock *before* reprogramming the PLL and waiting for it to relock. Then switch it back.

Don't select, or wait on, clocks that already set and valid.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
alfaez
Associate II
Posted on July 31, 2011 at 15:25

Actually, even if I disable PLL, HSE and HSI in the main application, it is still executed correctly using the bootloader clock !!!

Posted on July 31, 2011 at 16:49

Actually, even if I disable PLL, HSE and HSI in the main application, it is still executed correctly using the bootloader clock !!!

Then clearly you aren't doing those things, check your code flow.

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