GD32A50x User Manual
474
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 set the 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.
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.
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
oversampling 16 mode, the 7th, 8th, and 9th samples are used. If two or more samples of a
frame bit is 0, the frame bit is confirmed as a 0, else 1. If the value of the three samples of
any bit are not the same, whatever it is a start bit, data bit, parity bit or stop bit, a noisy error
(NERR) status will be generated for the frame. An interrupt will be generated, If the ERRIE
bit in USART_CTL2 register is set. If the OSB bit in USART_CTL2 register is set, the receiver
gets only one sample to evaluate a bit value. In this situation, no noisy error will be detected.