35.2.2.8 Asynchronous Reception Setup
Use the following steps as a guide for configuring the UART for asynchronous reception:
- Initialize the UxBRG register pair and the BRGS bit to achieve the desired baud rate.
- Configure the RXPPS register for the desired RX pin.
- Clear the ANSEL bit for the RX pin (if applicable).
- Set the MODE bits to the desired Asynchronous mode.
- Set the RXPOL bit if the data stream is inverted.
- Enable the serial port by setting the ON bit.
- If interrupts are desired, set the UxRXIE bit in the PIEx register and enable global interrupts.
- Enable reception by setting the RXEN bit.
- Read the UxERRIR register to get the error flags.
- The UxRXIF Interrupt Flag bit will be set when a character is transferred from the RSR to the receive buffer. An interrupt will be generated if the UxRXIE interrupt enable bit is also set.
- Read the UxRXB register to get the received byte.
- If an overrun occurred, clear the RXFOIF bit.