GD32W51x User Manual
594
Figure 18-3. USART transmit procedure
Write data0 to
USART_TDATA by
DMA or software
set by
hardware
Write data1 to
USART_TDATA by
DMA or software
Write data2 to
USART_TDATA by
DMA or software
set by
hardware
set by
hardware
USART_TDATA
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 to be asserted before disabling the USART or entering
the power saving mode. This bit can be cleared by writing 1 to TCC bit in USART_INTC
register.
The break frame is sent when the SBKCMD bit is set, and SBKCMD bit is reset after the
transmission.
18.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.
6.
Set the REN bit in USART_CTL0.
After being enabled, the receiver receives a bit stream after a valid start pulse has been
detected. Detection on noisy error, parity error, frame error and overrun error is performed
during the reception of a frame.
When a frame is received, the RBNE bit in USART_STAT is asserted, an interrupt is
generated if the corresponding interrupt enable bit (RBNEIE) is set in the USART_CTL0
register. The status of the reception are stored in the USART_STAT register.
The software can get the received data by reading the USART_RDATA register directly, or
through DMA. The RBNE bit is cleared by a read operation on the USART_RDATA register,
whatever it is performed by software directly, or through DMA.
The REN bit should not be disabled when reception is ongoing, or the current frame will be
lost.
By default, the receiver gets three samples to evaluate the value of a frame bit. If the
oversampling 8 mode is enabled, the 3rd, 4th and 5th samples are used, while in the