cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746 CubeMX clock not reporting correctly?

Jeremy Vance_2
Associate III
Posted on October 25, 2017 at 18:38

I'm using an STM32F746VGT6 microcontroller configured from STM32CubeMX for all the clocks and I'm getting roughly 220% higher clock rates reported for SystemCoreClock when compiled. For instance I have an HSE crystal at 11.2896MHz with the following main PLL settings:

PLLM /11

PLLN *234

PLLP /2

PLLQ /5

I have selected HSE for PLL source and PLLCLK as System Clock Source. Doing that in STM32CubeMX yields 120.080291MHz.

However, after SystemClock_Config(), SystemCoreClock = 265909059.

Due to that discrepancy, the microcontroller thinks it's working 220% faster than it actually is so all my timings are off by that much.

My first clue was when I configured SAI_BlockA1 and measured MCLK to be double than expected.  Then testing an output with HAL_Delay(50) gave me actual delay of 110ms.

Has anyone else seen this issue and what could be the problem here? Thanks for any insight.

0690X00000608kWQAQ.png

#stm32f746 #stm32cubemx
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on October 25, 2017 at 21:29

Okay, I figured it out.  I use VisualGDB with Visual Studio.  They generated a conf as well and while I removed it from the solution, it was still being compiled (HSE set to 25MHz).  Only when I used find all references did I find the other file still being used.

Thanks Clive.  Your 25MHz note helped me find this.

View solution in original post

5 REPLIES 5
Posted on October 25, 2017 at 18:45

Does HSE_VALUE get set to something appropriate? stm32f7xx_hal_conf.h ??

#define HSE_VALUE 

11289600 // rather than 8000000 or 25000000

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on October 25, 2017 at 18:48

Math works as if it uses 25 MHz for speed computations.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on October 25, 2017 at 21:20

Straight from stm32f7xx_hal_conf.h:

♯ if !defined (HSE_VALUE)

♯ define HSE_VALUE ((uint32_t)11289600U) /*!< Value of the External oscillator in Hz */

♯ endif /* HSE_VALUE */

So, yes.  It is set.  You're right though.  Put in 25MHz and it does indeed come out to the same frequency it is reporting as SystemClock.

Is there another place this value could be overwritten (not that a define can be overwritten) with?  This program is straight from CubeMX.

Posted on October 25, 2017 at 21:27

Not using F7 + CubeMX in this context, would suggest grepping for HSE_VALUE in the source, probably used in RCC macros or source in computation of bus clocks, etc. In Keil you can mouse over things and see value in given source.

In some contexts can be pulled as a command-line define, but if conf.h is pulled it would redefine.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on October 25, 2017 at 21:29

Okay, I figured it out.  I use VisualGDB with Visual Studio.  They generated a conf as well and while I removed it from the solution, it was still being compiled (HSE set to 25MHz).  Only when I used find all references did I find the other file still being used.

Thanks Clive.  Your 25MHz note helped me find this.