AT32F421
Series Reference Manual
2022.11.11
Page 141
Rev 2.02
buffer.
In non-DMA mode, both FERR and RDBF are set at the same time. The latter will generate an
interrupt. In DMA mode, an interrupt is generated if the ERRIEN.
When an overrun error occurs:
The ROERR bit is set.
The data in the receive data buffer is not lost. The previous data is still available when the
USART_DT register is read.
The content in the receive shift register is overwritten. Afterwards, any data received will be lost.
An interrupt is generated if the RDBFIEN is set or both ERRIEN and DMAREN are set.
The ROERR bit is cleared by reading the USART_STS register and then USART_DT register.
Note: If ROERR is set, it indicates that at least one piece of data is lost, with two possibilities:
If RDBF=1, it indicates that the last valid data is still stored in the receive data buffer, and
can be read.
If RDBF=0, it indicates that the last valid data in the receive data buffer has already been
read.
Note: The REN bit cannot be reset during data reception, or the byte that is currently being received will
be lost.
12.8.3 Start bit and noise detection
A start bit detection occurs when the REN bit is set. With the oversampling techniques, the USART
receiver samples data on the 3rd, 5th, 7th, 8th, 9th and 10th bits to detect the valid start bit and noise.
shows the data sampling over start bit and noise detection.
Table 12-2
Data sampling over start bit and noise detection
Sampled value (3·5·7)
Sampled value (8·9·10)
NERR bit
Start bit validity
000
000
0
Valid
001/010/100
001/010/100
1
Valid
001/010/100
000
1
Valid
000
001/010/100
1
Valid
111/110/101/011
Any value
1
Invalid
Any value
111/110/101/011
1
Invalid
Note: If the sampling values on the 3rd, 5th, 7th, 8th, 9th, and 10th bits do not match the above
mentioned requirements, the USART receiver does not think that a correct start bit is
received, and thus it will abort the start bit detection and return to idle state waiting for a
falling edge.
The USART receiver has the ability to detect noise. In the non-synchronous mode, the USART receiver
samples data on the 7
th
, 8
th
and 9
th
bits, with its oversampling techniques, to distinguish valid data input
from noise based on different sampling values, and recover data as well as set NERR flag (Noise Error
Flag) bit.
Table 12-3
Data sampling over valid data and noise detection
Sampled value
NERR bit
Received bit value
Data validity
000
0
0
Valid
001
1
0
Invalid
010
1
0
Invalid
011
1
1
Invalid
100
1
0
Invalid
101
1
1
Invalid
110
1
1
Invalid
111
0
1
Valid
When noise is detected in a data frame:
The NERR bit is set at the same time as the RDBF bit
The invalid data is transferred from the receive shift register to the receive data buffer.
No interrupt is generated in non-DMA mode. However, since the NERR bit and RDBF bit are set
simultaneously, the RDBF bit will generate an interrupt. In DMA mode, an interrupt will be
generated if the ERRIEN is set.
The NERR bit is cleared by reading USART_STS register and then the USART_DT register.