Initialize the SPxBRGH:SPxBRGL register pair and set or clear
the BRG16 bit, as required, to achieve the desired baud rate.
Select the receive input pin by writing the appropriate values to the RxyPPS register
and RXxPPS register. Both selections should enable the same pin.
Select the clock output pin by writing the appropriate values to the RxyPPS register
and CKxPPS register. Both selections should enable the same pin.
Clear the ANSEL bit for the RXx pin (if applicable).
Enable the synchronous master serial port by setting bits SYNC, SPEN and CSRC.
Ensure bits CREN and SREN are clear.
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 bit RX9.
Start reception by setting the SREN bit or for continuous reception, set the CREN bit.
Interrupt flag bit RCxIF will be set when reception of a character is complete. An interrupt will be generated if the enable bit RCxIE was set.
Read the RCxSTA register to get the ninth bit (if enabled) and determine if any error occurred during reception.
Read the 8-bit received data by reading the RCxREG register.
If an overrun error occurs, clear the error by either clearing the CREN bit of the RCxSTA register or by clearing the SPEN bit which resets the EUSART.
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.