Skip to main content
baranovus
Associate III
August 13, 2010
Question

USART_BRR value calculation

  • August 13, 2010
  • 2 replies
  • 700 views
Posted on August 13, 2010 at 21:48

USART_BRR value calculation

    This topic has been closed for replies.

    2 replies

    picguy2
    Associate III
    May 17, 2011
    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).

    Tesla DeLorean
    Guru
    May 17, 2011
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..