cancel
Showing results for 
Search instead for 
Did you mean: 

Configure System Clock STM32F0XX

colmolungma
Associate II
Posted on March 27, 2017 at 19:30

Dear All. I'm using STM32F051 with 12 MHz crystal. but my serial communication ran 1.5X faster then i set.I think i need to configure HSE. i have editted ->  #define HSE_VALUE    ((uint32_t)12000000) but still doesn't work.

3 REPLIES 3
Posted on March 27, 2017 at 21:20

Perhaps in the wrong place? In Keil I'd try mousing over the use of HSE_VALUE in system_stm32f0xx.c and stm32f0xx_rcc.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
colmolungma
Associate II
Posted on March 27, 2017 at 23:30

as your advice, i am looking at system_stm32f0xx.c and found

/* PLL configuration = HSE * 6 = 48 MHz */

RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));

RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLMULL6);

i see, HSE multiplied by 6

than i try to change it to  ......| RCC_CFGR_PLLMULL4); and now it works fine.

curiously, i try write HSE at stm32f0xx.h back to 8000000, but it still works. maybe because i have set xtal at option for target 'target1' as 12 MHz.

thank you, clive one.

Posted on March 27, 2017 at 23:33

HSE_VALUE tends to be critical when selecting USART baud rates, it is used with the RCC clocks, and decoded PLL settings, to compute the APBx speeds

The PLL settings are more like gears, as long as the ratios are right the clocks will run how you set them regardless of HSE_VALUE

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