Skip to main content
pk84
Associate III
September 13, 2019
Question

Setup UART Baudrate 9600, but output is 4800?? (STM32F103C8Tx, blue pill)

  • September 13, 2019
  • 5 replies
  • 1960 views

Hello, I'm a newbie with STM32.

I transmit data over the UART interface and I have configured 9600 Baudrate, but I can only receive the correct data on my PC terminal if I setup to 4800.. So why the Baudrate is effectively 2 times lower? I'm using the blue pill board with the STM32F103C8Tx, and clock configuration Sysclk,Hcclk is 72Mhz, setup with STM32CubeMx. (no warnings at build)

sorry my poor english.

thank you very much

This topic has been closed for replies.

5 replies

Tesla DeLorean
Guru
September 13, 2019

The define for HSE_VALUE likely disagrees with crystal in use. Check clocks and PLL settings

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
pk84
pk84Author
Associate III
September 13, 2019

thanks, see attached my clock configuration. unfortunately I have no idea which parameters I must change for that. The external crystal is a 8.000 MHz.

0690X00000ARBycQAH.png

pk84
pk84Author
Associate III
September 13, 2019

update, if I change PLL Source Mux to HSI it works... very special?!.

what do to use the external clock correctly?

Tesla DeLorean
Guru
September 13, 2019

Make sure a) the hardware actually clocks properly, get a scope and measure, output internal clocks via PA8 (MCO) pin, and b) that the setting of HSE_VALUE is coherent, ie HW and SW working from the same set of facts, so the computations will work correctly for the baud rate divider settings.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
JoniS
Senior
September 13, 2019

You must define HSE_VALUE at project level, of course mathcing the actual crystal value.

Its not once or twice that I have done the mistake of not doing so, ​and then chased ghost's only because cube failed to generate the correct clock value in code.(for reason or another it does like to set the HSE_VALUE = 25mhz, no matter what i put in the text box)

Piranha
Principal III
September 13, 2019

Also, when using crystal, make sure that HSE bypass mode is not enabled.