Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.