Initialize the SPxBRGH, SPxBRGL register pair and the BRGH and
BRG16 bits to achieve the desired baud rate (see EUSART Baud Rate Generator (BRG)).
Select the transmit output pin by writing the appropriate value to the RxyPPS
register.
Enable the asynchronous serial port by clearing the SYNC bit and setting the SPEN bit.
If 9-bit transmission is desired, set the TX9 control bit in the
TXxSTA register. That will indicate that the eight Least Significant data bits are an
address when the receiver is set for address detection.
Set the SCKP bit if inverted transmit is desired.
Enable the transmission by setting the TXEN control bit. This will cause the TXxIF interrupt bit to be set.
If interrupts are desired, set the TXxIE interrupt enable bit of
the PIE3 register.
An interrupt will occur immediately provided that the GIE and
PEIE bits of the INTCON register are also set.
If 9-bit transmission is selected, the ninth bit may be loaded
into the TX9D data bit.
Load 8-bit data into the TXxREG register. This will start the transmission.
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.