Initialize the SPxBRGH:SPxBRGL register pair and the BRGH and
BRG16 bits to achieve the desired baud rate (see the 29.2 EUSART Baud Rate Generator (BRG) section).
Set the RXxPPS register to select the RXx/DTx input pin.
Clear the ANSEL bit for the RXx pin (if applicable).
Enable the serial port by setting the SPEN bit. The SYNC bit must be clear for asynchronous operation.
If interrupts are desired, set the RCxIE bit of the PIEx
register and the GIE and PEIE bits of the INTCON register.
If 9-bit reception is desired, set the RX9 bit.
Enable reception by setting the CREN bit.
The RCxIF 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 RCxIE interrupt enable bit was also set.
Read the RCxSTA register to get the error flags and, if 9-bit data reception is enabled, the ninth data bit.
Get the received eight Least Significant data bits from the receive buffer by reading the RCxREG register.
If an overrun occurred, clear the OERR flag by clearing the CREN receiver enable bit.
The online versions of the documents are provided as a courtesy. Verify all content and data in the device’s PDF documentation found on the device product page.