cancel
Showing results for 
Search instead for 
Did you mean: 

Can't launch stm32f107x_cl from external clock

danashevskiy
Associate II
Posted on October 07, 2015 at 11:42

In my project with stm32f107 i use 25 MHz quartz crystal multiplying it to 48 MHz.

In IAR project preprocessor options i defined:

STM32F107
STM32F10X_CL

In stm32f10x.h i defined:

#define HSE_VALUE ((uint32_t)25000000)

in system_stm32f10x.c i defined:

#define SYSCLK_FREQ_48MHz 48000000

After detecting timing troubles in project i decided to check system frequencies with the help of RCC_GetClocksFreq function.

RCC_GetClocksFreq(&RCC_ClockFreq);
printf(
''sys clk: %d\n''
, RCC_ClockFreq.SYSCLK_Frequency);
printf(
''hclk: %d\n''
, RCC_ClockFreq.HCLK_Frequency);
printf(
''adc clk: %d\n''
, RCC_ClockFreq.ADCCLK_Frequency);
printf(
''pclk1: %d\n''
, RCC_ClockFreq.PCLK1_Frequency);
printf(
''pclk1: %d\n''
, RCC_ClockFreq.PCLK2_Frequency);

And printf results are all ''0''! In other way setting HSE_VALUE as system clock source gives ''1''. Have i missed something or i should look for mistake on a hardware level.'? #hse #stm32f107
2 REPLIES 2
AvaTar
Lead
Posted on October 07, 2015 at 12:44

>In my project with stm32f107 i use 25 MHz quartz crystal multiplying it to 48 MHz.

 

Not sure how this can be achieved with integral PLL multipliers.

I guess setting up the HSE clock fails, possibly falling back to HSI.

That depends on your startup code. Usually, this is done in the function

SystemInit()

, which in turn calls

SetSysClock

() to setup clock and PLL.

I would suggest to debug this functions.

If no PLL is used,

RCC_GetClocksFreq()

returns a fixed, (usually) non-zero value, either HSE_VALUE or HSI_VALUE.

Posted on October 07, 2015 at 15:12

The PLL and clocking on the 105/107 parts is more flexible that the other 10x parts

If you suspect the hardware, have the clock exported by MCO pin (PA8) and validate it.

You can walk the code in system_stm32f10x.c to see what values are coded into the PLL, a lot of this stuff has historically been hard coded, so you'll need to check the values are correct for your board. Just changing HSE_VALUE may be inadequate, and it's a variable used to decompose the internal settings (as read from registers) for timing purposes, like USART baud rates.

If the clock function is returning zeros, check the source, it could be the result of an error condition.

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