30.1.1.7 Asynchronous Transmission Setup

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