cancel
Showing results for 
Search instead for 
Did you mean: 

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

KMaen
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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

Check HSE_VALUE define in stm32f7xx_hal_conf.h​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KMaen
Associate III

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