GD32F20x User Manual
492
The USART transmit procedure is shown in
Figure 19-3. USART transmit procedure
. The
software can follow this flow:
1.
Set the UEN bit in USART_CTL0 to enable the USART.
2.
Write the WL bit in USART_CTL0 to set the data bits length.
3.
Set the STB[1:0] bits in USART_CTL1 to configure the number of stop bits.
4.
Enable DMA (DENT bit) in USART_CTL2 if multibuffer communication is selected.
5.
Set the baud rate in USART_BAUD.
6.
Set the TEN bit in USART_CTL0.
7.
Wait for the TBE being asserted.
8.
Write data into the USART_DATA register.
9.
Repeat step7-8 for each data, if DMA is not enabled.
10. Wait until TC=1 to finish.
Figure 19-3. USART transmit procedure
Write data0 to
USART_DATA by
DMA or software
set by hardware
Write data1 to
USART_DATA by
DMA or software
Write data2 to
USART_DATA by
DMA or software
set by hardware
set by hardware
USART_DATA
TBE
TEN
TX pin
idle frame
frame0
frame1
frame2
data0
data1
data2
set by hardware
cleared by
software
TC
It is necessary to wait for the TC bit asserted before disabling the USART or entering the
power saving mode. This bit can be cleared by a software sequence: reading the
USART_STAT0 register and then writing the USART_DATA register. If the multibuffer
communication is selected (DENT=1), this bit can also be cleared by writing 0 to it directly.
19.3.4.
USART receiver
After power on, the USART receiver can be enabled by the following procedure:
1.
Write the WL bit in USART_CTL0 to set the data bits length.
2.
Set the STB[1:0] bits in USART_CTL1.
3.
Enable DMA (DENR bit) in USART_CTL2 if multibuffer communication is selected.
4.
Set the baud rate in USART_BAUD.
5.
Set the UEN bit in USART_CTL0 to enable the USART.
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...