English
Language : 

PIC16F722A Datasheet, PDF (144/284 Pages) Microchip Technology – 28-Pin Flash Microcontrollers with nanoWatt XLP Technology
PIC16F/LF722A/723A
16.2 AUSART Baud Rate Generator
(BRG)
The Baud Rate Generator (BRG) is an 8-bit timer that
is dedicated to the support of both the asynchronous
and synchronous AUSART operation.
The SPBRG register determines the period of the free
running baud rate timer. In Asynchronous mode the
multiplier of the baud rate period is determined by the
BRGH bit of the TXSTA register. In Synchronous mode,
the BRGH bit is ignored.
Table 16-3 contains the formulas for determining the
baud rate. Example 16-1 provides a sample calculation
for determining the baud rate and baud rate error.
Typical baud rates and error values for various
asynchronous modes have been computed for your
convenience and are shown in Table 16-3. It may be
advantageous to use the high baud rate (BRGH = 1), to
reduce the baud rate error.
Writing a new value to the SPBRG register causes the
BRG timer to be reset (or cleared). This ensures that
the BRG does not wait for a timer overflow before
outputting the new baud rate.
EXAMPLE 16-1: CALCULATING BAUD
RATE ERROR
For a device with FOSC of 16 MHz, desired baud rate of
9600, and Asynchronous mode with SYNC = 0 and BRGH
= 0 (as seen in Table 16-3):
Desired Baud Rate = 6---4------S---P-F---B-O---R-S--G-C-----+------1----
Solving for SPBRG:
SPBRG
=


6----4------D----e---s--i--r-F-e---dO----BS---C-a---u---d----R----a---t--e---
–1
=


6-1---46---0---09---06---00---00---0--
–1
= 25.042 = 25
Actual Baud Rate = 6--1-4--6---0-2--0-5--0---+0---0--1-0---
= 9615
%
Error
=


-A----c---t--u---a----l---B----a--D-u---de---s--Ri--r-a-e--t-d-e---B-–---a--D-u---ed---s--Ri--r-a-e--t-d-e---B----a---u---d----R----a---t--e--
100
=


9---6---1---95---6--–-0---09---6---0---0--
100
=
0.16%
TABLE 16-3: BAUD RATE FORMULAS
Configuration Bits
SYNC
BRGH
AUSART Mode
0
0
Asynchronous
0
1
Asynchronous
1
x
Synchronous
Legend: x = Don’t care, n = value of SPBRG register
Baud Rate Formula
FOSC/[64 (n+1)]
FOSC/[16 (n+1)]
FOSC/[4 (n+1)]
TABLE 16-4: REGISTERS ASSOCIATED WITH THE BAUD RATE GENERATOR
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
RCSTA
SPBRG
TXSTA
Legend:
SPEN
RX9
SREN CREN ADDEN FERR OERR RX9D 0000 000x
BRG7 BRG6 BRG5 BRG4 BRG3 BRG2 BRG1 BRG0 0000 0000
CSRC
TX9
TXEN SYNC
—
BRGH TRMT TX9D 0000 -010
x = unknown, - = unimplemented read as ‘0’. Shaded cells are not used for the Baud Rate Generator.
Value on
all other
Resets
0000 000x
0000 0000
0000 -010
DS41417A-page 144
 2010 Microchip Technology Inc.