cancel
Showing results for 
Search instead for 
Did you mean: 

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

pk84
Senior

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

6 REPLIES 6

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
pk84
Senior

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
Senior

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

what do to use the external clock correctly?

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 Venmo Up vote any posts that you find helpful, it shows what's working..
JoniS
Senior

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
Chief II

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