AT32F421
Series Reference Manual
2022.11.11
Page 139
Rev 2.02
12.7 Transmitter
12.7.1 Transmitter introduction
USART transmitter has its individual TEN control bit. The transmitter and receiver share the same baud
rate that is programmable. There is a transmit data buffer (TDR) and a transmit shift register in the
USART. The TDBE bit is set whenever the TDR is empty, and an interrupt is generated if the TDBEIEN
is set.
The data written by software is stored in the TDR register. When the shift register is empty, the data will
be moved from the TDR register to the shift register so that the data in the transmit shift register is output
on the TX pin in LSB mode. The output format depends on the programmed frame format.
If synchronous transfer or clock output is selected, the clock pulse is output on the CK pin. If the hardware
flow control is selected, the control signal is input on the CTS pin.
Note: 1. The TEN bit cannot be reset during data transfer, or the data on the TX pin will be
corrupted.
2. After the TEN bit is enabled, the USART will automatically send an idle frame.
12.7.2 Transmitter configuration
1. USART enable: Set the UEN bit to 1.
2. Full-duplex/half-duplex configuration: Refer to
12.2 Full-duplex/half-duplex selector
3. Mode configuration: Refer to
4. Frame format configuration: Refer to
12.4 USART frame format and configuration
5. Interrupt configuration: Refer to
6. DMA transfer configuration: To use DMA mode for data transfer, the DMATEN bit (bit 7 in the
USART_CTRL3register) should be set, and the DMA register should be configured accordingly.
7. Baud rate configuration: Refer to
8. Transmitter enable: When the TEN bit is set to 1, the USART transmitter will automatically send
an idle frame.
9. Write operation: Wait until the TDBE bit is set, and the data to be transferred are written into the
USART_DT register (This operation will clear the TDBE bit). Repeat this step in non-DMA mode.
10. After the last data expected to be transferred is written, wait until the TDC is set, indicating the end
of transfer. The USART cannot be disabled before the flag is set, or transfer error will occur.
11. When TDC=1, reading USART_STS register once and writing to the USART_DT register once can
clear the TDC bit; It
can also be cleared by writing “0” to itself, but this is valid only in DMA mode.
Figure 12-10 TDC/TDBE behavior when transmitting
TDBE
USART_DT
DATA0
DATA1
DATA2
TX pin
TDC
TEN
Set by hardware
Set by hardware
Set by hardware
Set by hardware
Cleared by software
Idle frame
frame0
frame1
frame2