645
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
PCLK2 is used for USART1, UART6, UART7, up to 72MHz.
USARTDIV is an unsigned fixed-point number.
USARTDIV and USART_BRCF register configuration
Example 1:
If USARTDIV = 27.75, then
:
DIV_Decimal = 16*0.75 = 12 = 0x0C
DIV_Integer = 27=0x1B
So USART_BRCF = 0x1BC
Example 2:
If USARTDIV = 20.98, then
:
DIV_Decimal = 16*0.98 = 15.68
Nearest integer: DIV_Decimal = 16 = 0x10, out of configurable range, so a carry to integer is required
So DIV_Integer = 20+1 = 21 = 0x15
DIV_Decimal = 0x0
So USART_BRCF = 0x150
Example 3:
If USART_BRCF = 0x19B
:
DIV_Integer = 0x19 = 25
DIV_Decimal = 0x0B = 11
So USARTDIV = 25+11/16 = 25.6875
Table 23-3 Error calculation when setting baud rate
Baud rate
f
PCLK
=36MHz
f
PCLK
=72MHz
serial
number
Kbps
reality
Set value in register
Error(%)
reality
Set value in register
Error(%)
1
2.4
2.4
937.5
0%
2.4
1875
0%
2
9.6
9.6
234.375
0%
9.6
468.75
0%
3
19.2
19.2
117.1875
0%
19.2
234.375
0%
4
57.6
57.6
39.0625
0%
57.6
78.125
0%
5
115.2
115.384
19.5
0.15%
115.2
39.0625
0%