Skip to main content
Pavel A.
February 23, 2018
Solved

CubeMX generates incorrect system clock init code?

  • February 23, 2018
  • 6 replies
  • 2448 views
Posted on February 23, 2018 at 01:56

Still very fresh with CubeMX and all this STM32 stuff, hope it is my fault. Or not?

In the Clock configuration tab in Cube 4.23 I've produced configuration that should set the HCLK and SYSCLK to 72 MHz

(not sure how it calculated this config, I have external osc. 8 MHz and must have 48 MHz for USB). The chip is STM32F446. See the picture below.

But, in the generated code in main.c after SystemClock_Config()  SystemCoreClock value is 225,000,000.

If I understand correctly SystemCoreClock should be exactly the HCLK (or Sysclk?)

I know that the actual frequency is 72 MHz because I use debug output via ITM_SendChar, and entered 72Mhz in Keil debug settings. It prints   

0690X00000609g6QAA.png

Today I upgraded this project to Cube v. 4.24 and libraries 1.19.0 and the  

SystemCoreClock value still is 225,000,000.

This may be related to

https://community.st.com/0D50X00009Xkav1SAB

.

Please advice...

Regards,

-- pa

#cubemx-4.23 #stm32f446 #cubemx-v4.24
This topic has been closed for replies.
Best answer by waclawek.jan
Posted on February 23, 2018 at 07:10

Incorrect HSE_VALUE?

I don't Cube.

JW

6 replies

waclawek.jan
waclawek.janBest answer
Super User
February 23, 2018
Posted on February 23, 2018 at 07:10

Incorrect HSE_VALUE?

I don't Cube.

JW

Pavel A.
Pavel A.Author
February 24, 2018
Posted on February 24, 2018 at 03:23

> 

Incorrect HSE_VALUE? 

The HSE comes from Master Clock Output of another STM32F446 where it is set to repeat it's 8 MHz HSE.

So I defined it as 8 MHz in  BYPASS mode.

There are too many multipliers and various buses to keep in mind, for me is the main reason to use the Cube. The GUI factor. C code puts my h/w engineer in high-impedance state. Only when he sees the GUI, he is contactable.

-- pa

waclawek.jan
Super User
February 24, 2018
Posted on February 24, 2018 at 09:27

I mean, incorrectly defined symbol HSE_VALUE

---

Please don't confuse Cube (the 'library') with CubeMX. CubeMX (the GUI) can still be used for clicking, without using the 'library' or generated code. We do exactly this with my colleague who does the HW.

I prefer to print out the clock tree from the RM or the pin list from DS (or

http://www.efton.sk/STM32/STM32F4xx%20misc.pdf

) and use colored pens and highlighters.

JW

JObr
Associate II
September 26, 2019

I had another issue when my HSE_VALUE was overridden by defaut value, see https://github.com/platformio/platform-ststm32/issues/290. It's in PlatformIO.