[patch] improved rounding of UART clocks on STM32

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Posts: 139
Joined: Mon Sep 25, 2017 8:27 am
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 20 times

[patch] improved rounding of UART clocks on STM32

Postby tridge » Fri Aug 03, 2018 5:08 am

This patch fixes the rounding in calculating BRR for UARTv1 and UARTv2 for STM32. It was originally done by Jon Challenger, and I'm submitting it here for him.
It fixes an issue with a STM32 talking to a RaspberryPi at 921600 baud. With STM32_PCLK1=42000000 and speed=921600 the code would come up with a BRR of 45. With this fix the BRR comes out as 46.
A value of 45 gives an error of 1.27% in the desired baudrate. A value of 46 gives an error of 0.94%. Perhaps surprisingly, this makes all the difference when talking to the RaspberryPi, and the link starts working.
Patch is against branch 18.2.x, tested on STM32F427, STM32F405 and STM32F765
Cheers, Tridge
(1.03 KiB) Downloaded 80 times

User avatar
Site Admin
Posts: 13717
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 916 times
Been thanked: 778 times

Re: [patch] improved rounding of UART clocks on STM32

Postby Giovanni » Sun Jan 06, 2019 5:22 pm


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 2 guests