34.2.2.8 Asynchronous Reception Setup

Use the following steps as a guide for configuring the UART for asynchronous reception:

  1. Initialize the UxBRG register pair and the BRGS bit to achieve the desired baud rate.
  2. Configure the RXPPS register for the desired RX pin.
  3. Clear the ANSEL bit for the RX pin (if applicable).
  4. Set the MODE bits to the desired Asynchronous mode.
  5. Set the RXPOL bit if the data stream is inverted.
  6. Enable the serial port by setting the ON bit.
  7. If interrupts are desired, set the UxRXIE bit in the PIEx register and enable global interrupts.
  8. Enable reception by setting the RXEN bit.
  9. Read the UxERRIR register to get the error flags.
  10. 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.
  11. Read the UxRXB register to get the received byte.
  12. If an overrun occurred, clear the RXFOIF bit.
Figure 34-5. UART Asynchronous Reception