10.1 Baud-rate generator BRG
The UART module includes a dedicated 16-bit baud rate generator with a prescaler. The UxBRG register controls the period of a free-running 16-bit timer:
the value of the UxBRG register for a specified baud rate is given by
Example:
If FCY=8MHz, and the desired baud rate is 9600, by applying the above expression one obtains the value UxBRG=(8•106/(16•9600))-1=51.083. After truncation to the integer value UxBRG=51. The truncation introduced a deviation from the desired baud rate. The new baud rate for UxBRG=51 is 9615.384, i.e. the deviation is 0.16%.
The baud rate and the deviation from a desired baud rate are strongly dependent on the basic clock of the device and the instruction cycle FCY. UART baud rates, baud rate deviations, and UxBRG register values as functions of the device instruction cycle frequencies are shown in Table 10-1.
BAUD RATE [KBPS] |
FCY=30MHZ |
FCY=25MHZ |
FCY=20MHZ |
FCY=16MHZ |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
0.3 |
0.3 |
0.0 |
6249 |
0.3 |
+0.01 |
5207 |
0.3 |
0.0 |
4166 |
0.3 |
+0.01 |
3332 |
1.2 |
1.1996 |
0.0 |
1562 |
1.2001 |
+0.01 |
1301 |
1.1996 |
0.0 |
1041 |
1.2005 |
+0.04 |
832 |
2.4 |
2.4008 |
0.0 |
780 |
2.4002 |
+0.01 |
650 |
2.3992 |
0.0 |
520 |
2.3981 |
-0.08 |
416 |
9.6 |
9.6154 |
+0.2 |
194 |
9.5859 |
-0.15 |
162 |
9.6154 |
+0.2 |
129 |
9.6154 |
+0.16 |
103 |
19.2 |
19.1327 |
-0.4 |
97 |
19.2901 |
+0.47 |
80 |
19.2308 |
+0.2 |
64 |
19.2308 |
+0.16 |
51 |
38.4 |
38.2653 |
-0.4 |
48 |
38.1098 |
-0.76 |
40 |
37.8788 |
-1.4 |
32 |
38.4615 |
+0.16 |
25 |
56 |
56.8182 |
+1.5 |
32 |
55.8036 |
-0.35 |
27 |
56.8182 |
+1.5 |
21 |
55.5556 |
-0.79 |
17 |
115 |
117.1875 |
+1.9 |
15 |
111.607 |
-2.95 |
13 |
113.6364 |
-1.2 |
10 |
111.1111 |
-3.38 |
8 |
250 |
|
|
|
|
|
|
250 |
0.0 |
4 |
250 |
0.0 |
3 |
500 |
|
|
|
|
|
|
|
|
|
500 |
0.0 |
1 |
MIN |
0.0286 |
0.0 |
65535 |
0.0238 |
0.0 |
65535 |
0.019 |
0.0 |
65535 |
0.015 |
0.0 |
65535 |
MAX |
1875 |
0.0 |
0 |
1562.5 |
0.0 |
0 |
1250 |
0.0 |
0 |
1000 |
0.0 |
0 |
BAUD RATE [KBPS] |
FCY=12MHZ |
FCY=10MHZ |
FCY=8MHZ |
FCY=7.68MHZ |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
0.3 |
0.3 |
0.0 |
2499 |
0.3 |
0.0 |
2082 |
0.2999 |
-0.02 |
1666 |
0.3 |
0.0 |
1599 |
1.2 |
1.2 |
0.0 |
624 |
1.1996 |
0.0 |
520 |
1.199 |
-0.08 |
416 |
1.2 |
0.0 |
399 |
2.4 |
2.3962 |
-0.2 |
312 |
2.4038 |
+0.2 |
259 |
2.4038 |
+0.16 |
207 |
2.4 |
0.0 |
199 |
9.6 |
9.6154 |
-0.2 |
77 |
9.6154 |
+0.2 |
64 |
9.6154 |
+0.16 |
51 |
9.6 |
0.0 |
49 |
19.2 |
19.2308 |
+0.2 |
38 |
18.9394 |
-1.4 |
32 |
19.2308 |
+0.16 |
25 |
19.2 |
0.0 |
24 |
38.4 |
37.5 |
+0.2 |
18 |
39.0625 |
+1.7 |
15 |
38.4615 |
+0.16 |
12 |
|
|
|
56 |
57.6923 |
-2.3 |
12 |
56.8182 |
+1.5 |
10 |
55.5556 |
-0.79 |
8 |
|
|
|
115 |
|
|
6 |
|
|
|
|
|
|
|
|
|
250 |
250 |
0.0 |
2 |
|
|
|
250 |
0.0 |
1 |
|
|
|
500 |
|
|
|
|
|
|
500 |
0.0 |
0 |
|
|
|
MIN |
0.011 |
0.0 |
65535 |
0.010 |
0.0 |
65535 |
0.008 |
0.0 |
65535 |
0.007 |
0.0 |
65535 |
MAX |
750 |
0.0 |
0 |
625 |
0.0 |
0 |
500 |
0.0 |
0 |
480 |
0.0 |
0 |
BAUD RATE [KBPS] |
FCY=5MHZ |
FCY=4MHZ |
FCY=3.072MHZ |
FCY=1.8432MHZ |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
KBAUD |
Error [%] |
BRG |
0.3 |
0.2999 |
0.0 |
1041 |
0.3001 |
0.0 |
832 |
0.3 |
0.0 |
639 |
0.3 |
0.0 |
383 |
1.2 |
1.2019 |
+0.2 |
259 |
1.2019 |
+0.2 |
207 |
1.2 |
0.0 |
159 |
1.2 |
0.0 |
95 |
2.4 |
2.4038 |
+0.2 |
129 |
2.4038 |
+0.2 |
103 |
2.4 |
0.0 |
79 |
2.4 |
0.0 |
47 |
9.6 |
9.4697 |
-1.4 |
32 |
9.6154 |
+0.2 |
25 |
9.6 |
0.0 |
19 |
9.6 |
0.0 |
11 |
19.2 |
19.5313 |
+1.7 |
15 |
19.2308 |
+0.2 |
12 |
19.2 |
0.0 |
9 |
19.2 |
0.0 |
5 |
38.4 |
39.0625 |
+1.7 |
7 |
|
|
|
38.4 |
0.0 |
4 |
38.4 |
0.0 |
2 |
56 |
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
500 |
|
|
|
|
|
|
|
|
|
|
|
|
MIN |
0.005 |
0.0 |
65535 |
0.004 |
0.0 |
65535 |
0.003 |
0.0 |
65535 |
0.002 |
0.0 |
65535 |
MAX |
312.5 |
0.0 |
0 |
250 |
0.0 |
0 |
192 |
0.0 |
0 |
115.2 |
0.0 |
0 |
Table 10-1 Baud rates, baud rate deviations, and UxBRG register values as functions of the device instruction cycle frequencies
Attention!
The minimum baud rate is FCY/(16•65535) for UxBRG=0xFFFF. The maximum baud rate is FCY/16 for UxBRG=0. Writing a new value to the UxBRG register causes the BRG timer to be cleared. This ensures that the BRG immediately starts generating the new baud rate.