# Microchips Reference manual calculated Desired Baud Rate

Status
Not open for further replies.

#### PA3040

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
MCU is 16f877a USART

Last edited:

#### bigdogguru

The equation shown in the second photo:

For BRGH = 0;

BAUD = Fosc/(64*(SPBRG + 1))

equates to:

SPBRG = (Fosc/(64*BAUD)) - 1

Which for BAUD = 9600 and Fosc = 16MHz calculates a SPBRG = 25.042.

Your version of the equation is missing the "1" subtracted from the the right hand side of the equation.

The actual BAUD rate generated is 9,615.38 and BAUD rate error is -0.2%.

BigDog

PA3040

### PA3040

Points: 2

#### PA3040

Dear BigDog
Thanks for reply, I got the point
Can I have the theory behind above math ( links of web)
Thanks once again

PA3040

### PA3040

Points: 2

Dear kak,

#### FvM

##### Super Moderator
Staff member
Can I have the theory behind above math ( links of web)
Which theory are you looking for?

- fosc divided by 4 makes fcy (instruction cycle frequency)
- fcy divided by (SPBRG+1) makes BCLK
- BCLK divided by an oversampling factor of 16 makes the actual baud rate

The data sheet linked by kak111 is explaining the baud generator "mathematics" in detail. Just read it...

PA3040

Points: 2