cancel
Showing results for 
Search instead for 
Did you mean: 

Setting HSI48 as STM32F072 sysclk

c_changkai
Associate II
Posted on July 17, 2016 at 16:53

I am trying to set HSI48 as my sysclock on STM32F0 Discovery, but by doing this I somehow ended up with an unexpected interrupt and stuck in an infinite loop.

I am using True Studio by the way. Not using CubeMX or peripheral lib, just old fashioned reg manipulating.

Anyone had any luck at this? Or are we stuck with HSI 8MHz x 8 PLL to get 48MHz CPU clock?

#hsi48-stm32f0
5 REPLIES 5
Posted on July 17, 2016 at 18:38

Not a part I'm actively using, but I would hazard you just need to get the register settings all correctly along the clocking paths, and with the flash wait states.

What interrupt? Stuck where? If you are in the Hard Fault handler, it is possible to do things more productive than while(1) loops. On the Cortex-Mx series if you fail to clear the source of an interrupt or fault it will keep coming back via the NVIC

Tips, Buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
c_changkai
Associate II
Posted on July 18, 2016 at 14:36

Hi,

It got stuck in Default_Handler. But the thing is that I made sure that the syclk switching is done only after all interrupts had been disabled, and only after the clock is ready.

It might be a Hard Fault, but I can't figure out how a simple clock switching can result in these things. After all, the same code worked well if I am switching to the slower 8MHz HSI.

I used only 8 bit micros all this while, and a little 16 bit micros. The complexity of the chip is quite overwhelming.
Posted on July 18, 2016 at 15:47

The complexity of the chip is quite overwhelming.

Register level programming doesn't scale well.

The FLASH array is speed sensitive. It will run fine at 8 MHz

Tips, Buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Walid FTITI_O
Senior II
Posted on July 18, 2016 at 19:19

Hi chai.ck,

Ensure that you have applied the recommendation in the reference manual:

''

The HSI48RDY flag in the Clock control register (RCC_CR) indicates if the HSI48 RC is stable or not. At startup, the HSI48 RC output clock is not released until this bit is set by hardware.

The HSI48 RC can be switched on and off using the HSI48ON bit in the Clock control register (RCC_CR). This oscillator will be also automatically enabled (by hardware forcing HSI48ON bit to one) as soon as it is chosen as a clock source for the USB and the peripheral is enabled.

''

-Hannibal-

c_changkai
Associate II
Posted on July 30, 2016 at 09:38

You're right. It ran fine after I set the flash latency setting in FLASH_ACR to 1