Skip to main content
KMaen
Associate III
October 24, 2019
Solved

Auto-generated SystemClock_Config() function makes UART baud rate 3x faster

  • October 24, 2019
  • 3 replies
  • 1081 views

I am trying to make UART printf work with STM32F746-DISCO board.

I tried running printf successfully with a default clock (whatever it is--I am not sure).

I was doing it without using STM32CubeMX code generator.

Now I found the code generator to be useful, I tried using the SystemClock_Config() function it generated for my board, which increases the clock speed up to 200MHz from my understanding.

However, when I increase the clock speed with the SystemClock_Config() function, my printf does not work.

Specifically, by using a logic analyzer, I figured that the baud rate becomes too fast, around 359689 (when I set it to 115200).

I am attaching my main code below -- it is mostly just a stripped-down version of what STM32CubeMX gave me.

If I comment out SystemClock_Config() from the code, the printf works fine.

Can anyone help me with what is happening?

Thank you

This topic has been closed for replies.
Best answer by waclawek.jan

From stm32f4xx_hal_rcc.c :

 * @note (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
 * 25 MHz), user has to ensure that HSE_VALUE is same as the real
 * frequency of the crystal used. Otherwise, this function may
 * have wrong result.

JW

3 replies

waclawek.jan
waclawek.janBest answer
Super User
October 24, 2019

From stm32f4xx_hal_rcc.c :

 * @note (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
 * 25 MHz), user has to ensure that HSE_VALUE is same as the real
 * frequency of the crystal used. Otherwise, this function may
 * have wrong result.

JW

Tesla DeLorean
Guru
October 24, 2019

Check HSE_VALUE define in stm32f7xx_hal_conf.h​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
KMaen
KMaenAuthor
Associate III
October 24, 2019

Thanks! I am using my own make in Linux and a wrong hal_conf.h file was getting included.