The UART module has the ability to operate in the loopback mode. This mode allows performing the corresponding self-tests. In order that the UART module operates in the loopback mode, it is required that the LPBACK (UxMODE<6>) control bit is set. In this mode the UxTX output is internally connected to the UxRX input, and the UxRX pin is disconnected from the internal UART receive logic. However, the UxTX pin still functions normally. Sending a message by the UART transmitter causes the reception of this message by the UART receiver. This allows checking if the UART module functions correctly.
To configure the UART module to operate in this mode, the following steps should be taken:
Configure UART for the desired mode of operation.
Set LPBACK=1 to enable loopback mode.
Enable transmission by setting the UARTEN (UxMODE<15>) and UTXEN (UxSTA<10>) control bits.