Checksums

Checksum calculations are used to verify that the data contained in a packet was transmitted/received correctly. When the Checksum Mode Select (C0EN) bit of UxCON2 is set, transmit and receive checksum adders accumulate the value of each byte transmitted or received.

In Transmit mode, the checksum adders accumulate the value of each byte transmitted. Once all bytes have been transmitted, the sum of the byte values are loaded into the UART Transmit Checksum Result (UxTXCHK) register, which is then sent as the final byte of the transmission.

In Receive mode, the checksum adders accumulate the value of each byte received. Once all bytes have been received, including the checksum byte, the sum of the received byte values are loaded into the UART Receive Checksum Result (UxRXCHK) register.

It is important to note that although UART hardware calculates the checksums and loads the results into the appropriate checksum registers, software must clear UxTXCHK and UxRXCHK before beginning UART transactions, and also performs the checksum comparisons at the end of each transaction.