Microchips Reference manual calculated Desired Baud Rate

Status
Not open for further replies.

micropad

Member
Dear All
Please see two image. one I calculated desired Baud Rate result and other
as per Manual The result of X is 25.042 and my calculation is 26.041
please advice wrong in my side
MCU is 16f877a USART
 
As an aside, I would recommend taking a look at the PIC Multi-Calc
 
Last edited by a moderator:
To reverse calculate the baud rate, you perform the equation as such (using 9600bps as the example) -

((16000000 / 9600) / 64) - 1 = 25.04

First divide 16000000 by the desired baud rate (9600) -

16000000 / 9600 = 1666.67

Then divide this answer by 64 -

1666.67 / 64 = 26.04

Then subtract 1 -

26.04 - 1 = 25.04

Since we cannot load SPBRG with anything but a whole number, we must round the result to the nearest 1...which gives us 25. This is going to give us an actual bit rate of -

16000000 / (64(25 + 1)) = 9615.38

This will give us an error percentage of -

((9615.38 - 9600) / 9600) x 100 = 0.16%

This is a more than acceptable error rate for 9600bps.

9600bps is one of those bit rates where you would have to use an odd value crystal speed to get exactly 9600bps with 0% error. This is one of the reasons why lots of microcontrollers use a crystal speed of 11.059MHz.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…