cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I find my clock settings in the code generated from CubeMX?

Sam F
Associate II
Posted on December 14, 2016 at 00:57

I see that SystemClock_Config(void) is generated, and shows the PLL divisions but it doesn't show anything about the actual clock speeds. Ultimately I'm trying to determine the speed of my ADC sampling but I'm having to work backward as I inherited code from somebody else where all the clocks were set already.

Thanks! 

#clocks #discovery #cubemx #stm32l476vg
1 ACCEPTED SOLUTION

Accepted Solutions
Sam F
Associate II
Posted on December 14, 2016 at 17:59

This is for the STM32L476VG Discovery board.  For the clock configuration I did a search for 'Hz' and eventually traced it back to the 'stml4xx_hal_conf.h' file.  In that file there is a section called 'Oscillator Values adaptation' that sets the values (in Hz) for the HSE, MSI, etc.. from there you can determine what your clock frequency is by looking at the PLL values set in SystemClock_Config.  

View solution in original post

2 REPLIES 2
shingadaddy
Senior
Posted on December 14, 2016 at 05:19

You don't mention your part number. So you have to know that and look up the default startup clock for that specific part and its default start frequency. Your data sheet will have a clock tree diagram ( or mine does anyway) and it has a system block diagram showing the buses and peripherals. Then which clocks are selected and enabled based on other clock sources *you* may have that are externally supplying the part. For an L476 -

PLLM  is a DIVIDER value.

PLLN is typically a MULTIPLIER value.

PLLP,Q and R are typically DIVIDER values.

That should get you started.

Sam F
Associate II
Posted on December 14, 2016 at 17:59

This is for the STM32L476VG Discovery board.  For the clock configuration I did a search for 'Hz' and eventually traced it back to the 'stml4xx_hal_conf.h' file.  In that file there is a section called 'Oscillator Values adaptation' that sets the values (in Hz) for the HSE, MSI, etc.. from there you can determine what your clock frequency is by looking at the PLL values set in SystemClock_Config.