
GD32L23x User Manual
452
Figure 20-3.
LPUART transmit procedure
Write data0 to
LPUART_TDATA by
DMA or software
set by
hardware
Write data1 to
LPUART_TDATA by
DMA or software
Write data2 to
LPUART_TDATA by
DMA or software
set by
hardware
set by
hardware
LPUART_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 LPUART or entering
the power saving mode. This bit can be cleared by set TCC bit in LPUART_INTC register.
The break frame is sent when the SBKCMD bit is set, and SBKCMD bit is reset after the
transmission. The break frame length depends on the WL[1:0] bits.
20.3.4.
LPUART receiver
After power on, the LPUART receiver can be enabled by the following procedure:
1.
Write the WL[1:0] bits in LPUART_CTL0 to set the data bits length.
2. Set the STB[1:0] bits in LPUART_CTL1.
3. Enable DMA (DENR bit) in LPUART_CTL2 if multibuffer communication is selected.
4. Set the baud rate in LPUART_BAUD.
5. Set the UEN bit in LPUART_CTL0 to enable the LPUART.
6. Set the REN bit in LPUART_CTL0.
After being enabled, the start bit is detected when a falling edge occurs on the RX line, and
then samples are taken in the middle of the start bit to confirm whether the level is still "0". If
the start sample is "1", the noise error flag (NERR) is set, the start bit will be discarded, and
the receiver will wait for a new start bit, an interrupt is generated, if the ERRIE bit in
LPUART_CTL2 register is set. The receiver receives a bit stream after a valid start pulse has
been detected. Detection on parity error, frame error and overrun error is performed during
the reception of a frame. The receiver gets a sample in the middle of the bit to evaluate its
value, there is no noise detection for data.
When a frame is received, the RBNE bit in LPUART_STAT is asserted, an interrupt is
generated if the corresponding interrupt enable bit (RBNEIE) is set in the LPUART_CTL0
register. The status of the reception are stored in the LPUART_STAT register.
The software can get the received data by reading the LPUART_RDATA register directly, or
through DMA. The RBNE bit is cleared by a read operation on the LPUART_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.