English
Language : 

PIC24HJ12GP201 Datasheet, PDF (146/234 Pages) Microchip Technology – High-Performance, 16-Bit Microcontrollers
PIC24HJ12GP201/202
16.1 UART Baud Rate Generator
The UART module includes a dedicated 16-bit BRG.
The BRGx register controls the period of a free-running
16-bit timer. Equation 16-1 shows the formula for
computation of the baud rate with BRGH = 0.
EQUATION 16-1: UART BAUD RATE WITH
BRGH = 0
Baud Rate =
FCY
16 • (BRGx + 1)
BRGx =
FCY
–1
16 • Baud Rate
Note: FCY denotes the instruction cycle clock
frequency (FOSC/2).
Example 16-1 shows the calculation of the baud rate
error for the following conditions:
• FCY = 4 MHz
• Desired Baud Rate = 9600
The maximum baud rate (BRGH = 0) possible is
FCY/16 (for BRGx = 0), and the minimum baud rate
possible is FCY/(16 * 65536).
Equation 16-2 shows the formula for computation of
the baud rate with BRGH = 1.
EQUATION 16-2: UART BAUD RATE WITH
BRGH = 1
Baud Rate =
FCY
4 • (BRGx + 1)
BRGx =
FCY
–1
4 • Baud Rate
Note: FCY denotes the instruction cycle clock
frequency (FOSC/2).
The maximum baud rate (BRGH = 1) possible is FCY/4
(for BRGx = 0), and the minimum baud rate possible is
FCY/(4 * 65536).
Writing a new value to the BRGx 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.
EXAMPLE 16-1: BAUD RATE ERROR CALCULATION (BRGH = 0)
Desired Baud Rate
=
Solving for BRGx Value:
BRGx =
BRGx =
BRGx =
Calculated Baud Rate =
=
Error
=
=
=
FCY/(16 (BRGx + 1))
((FCY/Desired Baud Rate)/16) – 1
((4000000/9600)/16) – 1
25
4000000/(16 (25 + 1))
9615
(Calculated Baud Rate – Desired Baud Rate)
Desired Baud Rate
(9615 – 9600)/9600
0.16%
DS70282B-page 144
Preliminary
© 2007 Microchip Technology Inc.