scratch4life
Posts: 2
Joined: Fri Jul 05, 2019 8:41 am

Pi4 - problem with UART baudrate (solved)

Fri Jul 05, 2019 9:37 am

Hi, I have a problem with UART changing baudrate during the operation of Python program.

I used clean buster image, installed all libraries necessary to run it, everything is fine for the first minute of program running, Raspberry sends 4 UART messages with 9600 baud just fine (and receiving responses ok) and then the next message is corrupted, I checked with logic analyzer and found that start bit was 2x longer than standard 9600 message, I checked and Rpi4 sends valid message but with changed baudrate to 4800, exactly 2 times slower than what was initialized. The same program runs just fine on Rpi 3B+.

I'm using BLE at the same time, but it seems to work fine (I get valid MAC address and form connection).
I already tried 'apt-get update' and 'apt-get upgrade'.

Have anyone experienced something like that? What could be a possible reason of that kind of behaviour?
I must also add that it's not my Python code (ex co-worker's), and Rpi 3B+ is running Jessie.
Last edited by scratch4life on Mon Jul 08, 2019 6:34 am, edited 1 time in total.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2123
Joined: Thu Jul 11, 2013 2:37 pm

Re: Pi4 - problem with UART baudrate

Fri Jul 05, 2019 6:28 pm

The baud rate scaling is the same issue as seen on RPI 3 and 3B+ - namely that the UART used on the GPIO pins gets its clock from the system bus clock which changes depending on system load.

If you absolutely need to use GPIO 14&15 and if you don't use bluetooth devices, then add "dtoverlay=pi3-disable-bt" to config.txt which will automatically swap the UART to the PL011. If you do need to use bluetooth devices, then add "core_freq_min=500" to config.txt to prevent core frequency scaling (but will result in increased idle power consumption).

If you can shift which GPIO pins you use, then there are many more UARTs on Pi4 - see
https://github.com/raspberrypi/linux/bl ... ADME#L2367
Rockets are loud.
https://astro-pi.org

scratch4life
Posts: 2
Joined: Fri Jul 05, 2019 8:41 am

Re: Pi4 - problem with UART baudrate

Mon Jul 08, 2019 6:33 am

I need to use BLE with UART so I added "core_freq_min=500" to config.txt and it worked flawlessly!

Thank you very much for help, I really appreciate your contribution :)

JimColvin
Posts: 2
Joined: Fri Jul 19, 2019 6:50 pm

Re: Pi4 - problem with UART baudrate (solved)

Wed Jul 24, 2019 5:55 am

I tried using UART 3 on the Pi4 and if enabled it kills the bluetooth as does all the other UART channels but 0. How do I use bluetooth and any UART's 1 thru 5 without conflict or masking of bluetooth. I was hoping these other channels were independent. Please advise.

Return to “Troubleshooting”