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
[patch] improved rounding of UART clocks on STM32
-
- Posts: 141
- Joined: Mon Sep 25, 2017 8:27 am
- Location: Canberra, Australia
- Has thanked: 10 times
- Been thanked: 20 times
- Contact:
[patch] improved rounding of UART clocks on STM32
- Attachments
-
- chibios_stm32_uart_clock_rounding.zip
- (1.03 KiB) Downloaded 192 times
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Return to “Small Change Requests”
Who is online
Users browsing this forum: No registered users and 37 guests