dsPIC30F Family Reference Manual
DS70066C-page 19-8 © 2004 Microchip Technology Inc.
19.3 UART Baud Rate Generator (BRG)
The UART module includes a dedicated 16-bit baud rate generator. The UxBRG register controls
the period of a free running 16-bit timer. Equation 19-1 shows the formula for computation of the
baud rate.
Equation 19-1: UART Baud Rate
Example 19-1 shows the calculation of the baud rate error for the following conditions:
•F
CY = 4 MHz
• Desired Baud Rate = 9600
Example 19-1: Baud Rate Error Calculation
The maximum baud rate possible is F
CY / 16 (for UxBRG = 0), and the minimum baud rate
possible is F
CY / (16 * 65536).
Writing a new value to the UxBRG register causes the BRG timer to be reset (cleared). This
ensures the BRG does not wait for a timer overflow before generating the new baud rate.
Note: F
CY denotes the instruction cycle clock frequency.
Baud Rate =
F
CY
16 • (UxBRG + 1)
FCY
16 • Baud Rate
UxBRG =– 1
Desired Baud Rate = FCY/(16 (UxBRG + 1))
Solving for UxBRG value:
UxBRG = ( (F
CY/Desired Baud Rate)/16) – 1
UxBRG = ((4000000/9600)/16) – 1
UxBRG = [25.042] = 25
Calculated Baud Rate = 4000000/(16 (25 + 1))
= 9615
Error = (Calculated Baud Rate – Desired Baud Rate)
Desired Baud Rate
= (9615 – 9600)/9600
=0.16%