AT32F421
Series Reference Manual
2022.11.11
Page 138
Rev 2.02
transfer in the DMA control register. Data will be loaded from the USART_DT register to the
programmed destination after reception request is received by DMA.
3.
Configure the source of DMA transfer: Configure the USART_DT register address as the source of
DMA transfer in the DMA control register. Data will be loaded from the USART_DT register to the
programmed destination after reception request is received by DMA.
4.
Configure the total number of bytes to be transferred in the DMA control register
(TMRx_DMACTRL).
5.
Configure the channel priority of DMA transfer in the DMA control register (TMRx_DMACTRL).
6.
Configure DMA interrupt generation after half or full transfer in the DMA control register
(TMRx_DMACTRL).
7.
Enable a DMA transfer channel in the DMA control register (TMRx_DMACTRL).
12.6 Baud rate generation
12.6.1 Introduction
USART baud rate generator uses an internal counter based on PCLK. The DIV (USART_BAUDR [15:0]
register) represents the overflow value of the counter. Each time the counter is full, it denotes one-bit
data. Thus each data bit width refers to PCLK cycles x DIV.
The receiver and transmitter of USART share the same baud rate generator, and the receiver splits each
data bit into 16 equal parts to achieve oversampling, so the data bit width should not be less than 16
PCLK periods, that is, the DIV value must be greater than 16.
12.6.2 Configuration
User can program the desired baud rate by setting different system clocks and writing different values
into the USART_BAUDR register. The calculation format is as follows:
TX
RX
𝑏𝑎𝑢𝑑 𝑟𝑎𝑡𝑒 =
𝑓
𝐶𝐾
DIV
Where,
𝑓
𝐶𝐾
refers to the system clock of USART (i.e. PCLK1/PCLK2 )
Note: 1.
Tthe USART_BAUDR register must be written before UEN. The baud rate register value should
not be altered when UEN=1.
2. Disabling USART receiver or transmitter will reset the internal counter, and generate a baud
rate interrupt.
Table 12-1
Baud rate calculation error
Baud rate
fPCLK=36MHz
fPCLK=72MHz
No.
Kbps
Actual
Value programmed in the
baud register
Error % Actual
Value programmed in the
baud register
Error %
1
2.4
2.4
15000
0%
2.4
30000
0%
2
9.6
9.6
3750
0%
9.6
7500
0%
3
19.2
19.2
1875
0%
19.2
3750
0%
4
57.6
57.6
625
0%
57.6
1250
0%
5
115.2 115.384
312
0.15%
115.2
625
0%
6
230.
4
230.769
156
0.16%
230.769 312
0.16%
7
460.
8
461.538
78
0.16%
461.538 156
0.16%
8
921.
6
923.076
39
0.16%
923.076 78
0.16%
9
2250 2250
16
0%
2250
32
0%
10
4500
NA
NA
NA
4500
16
0%
Taking a baud rate of 115.2Kbps as an example, if fPCLK=36MHz, the value in the baud register should be
set to 312(0x38). Based on formula, the calculated baud rate (actual) is 36000000 / 312 = 115384 =
115.384Kbps. The % error between the desired and actual value is calculated based on the formula:
(Calculated actual result-Desired)/desired baud rate*100%, that is, (115.384 - 115.2) / 115.2 * 100% = 0.15%.