[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.
tridge
Posts: 34
Joined: Mon Sep 25, 2017 8:27 am
Has thanked: 5 times
Been thanked: 5 times
Contact:

[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
Attachments
chibios_stm32_uart_clock_rounding.zip
(1.03 KiB) Downloaded 5 times

Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 0 guests