Skip to main content
KMaen
Associate III
Oct 24, 2019 2:51 AM UTC
Solved

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

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.
waclawek.jan
waclawek.janBest answer
Super User
Oct 24, 2019 5:33 AM UTC

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
Oct 24, 2019 5:33 AM UTC

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
Oct 24, 2019 11:24 AM UTC

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
Oct 24, 2019 4:44 PM UTC

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