25.3.4.8 Parity
Parity bits can be used by the USART to verify the validity of a data frame. The Parity bit
is set by the transmitter based on the number of bits with the value of
‘1’ in a transmission and controlled by the receiver upon reception. If
the Parity bit is inconsistent with the transmission frame, the receiver may assume that
the data frame has been corrupted.
Even or odd parity can be selected for error checking by setting the Parity Mode (PMODE)
bit field in the USARTn.CTRLD register. If even parity is selected, the Parity bit is set
to ‘1’ if the number of data bits with a value of ‘1’ is
odd (making the total number of bits with value ‘1’ even). If odd parity
is selected, the Parity bit is set to ‘1’ if the number of data bits with
a value of ‘1’ is even (making the total number of bits with value
‘1’ odd).
When enabled, the parity checker calculates the parity of the data bits in incoming frames and compares the result with the Parity bit of the corresponding frame. If a parity error is detected, the Parity Error flag (the PERR bit in the USARTn.RXDATAH register) is set.
