cancel
Showing results for 
Search instead for 
Did you mean: 

USART_BRR value calculation

baranovus
Associate III
Posted on August 13, 2010 at 21:48

USART_BRR value calculation

2 REPLIES 2
picguy2
Associate II
Posted on May 17, 2011 at 14:02

In the hardware, as opposed to the docs, the BRG is a simple integer, 16 times the baud rate.  Baud rate = input clock / (BRG*16).

Posted on May 17, 2011 at 14:02

I think they are just having some fun with fraction numbers using integer math.

As PICGuy notes, If you look at the hardware and know the USARTs internal clock needs to be 16X the baud rate, and the fractional part is 4-bits, you can get to a usable rate by dividing the APB clock for the USART by the baud rate desired and get a 12.4 fixed point representation.

Now even if I was worried about the rounding, I can see more elegant ways of achieving this with some 32-bit integer math than the ''beautiful'' ST example.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..