From 7c67322f753e9f33a98ea2393c8345db479abf69 Mon Sep 17 00:00:00 2001 From: Fergus Noble Date: Tue, 31 Jan 2012 15:11:17 -0800 Subject: Change stm32 usart baud rate generation to round rather than floor for more accurate divisor selection. --- lib/stm32/usart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/stm32/usart.c') diff --git a/lib/stm32/usart.c b/lib/stm32/usart.c index 3de0eb4..a2c9f16 100644 --- a/lib/stm32/usart.c +++ b/lib/stm32/usart.c @@ -52,8 +52,10 @@ void usart_set_baudrate(u32 usart, u32 baud) * marketting bable to sound awesome. It is nothing else but a * simple divider to generate the correct baudrate. >_< If I * am wrong feel free to correct me on that. :) (esden) + * + * Changed to round rather than floor (Fergus) */ - USART_BRR(usart) = clock / baud; + USART_BRR(usart) = (2*clock + baud) / (2*baud); } void usart_set_databits(u32 usart, u32 bits) -- cgit v1.2.3