Use the following steps as a guide for configuring the UART for asynchronous
transmissions.
- 1.Initialize the UxBRG register pair and the BRGS bit to achieve the desired baud rate.
- 2.Set the MODE bits to the desired asynchronous mode.
- 3.Set the TXPOL bit if inverted TX output is desired.
- 4.Enable the asynchronous serial port by setting the ON bit.
- 5.Enable the transmitter by setting the
TXEN Control bit. This will cause the UxTXIF Interrupt
flag to be set.
- 6.If the device has PPS, configure the
desired I/O pin RxyPPS register with the code for the TX output.
- 7.If interrupts are desired, set the
UxTXIE Interrupt Enable bit in the respective PIE register. An interrupt will occur
immediately provided that global interrupts are also enabled.
- 8.Write one byte of data into the UxTXB register. This will start the
transmission.
- 9.Subsequent bytes may be written when
the UxTXIF bit is ‘
1’.
Figure 1. UART Asynchronous Transmission
Figure 2. UART Asynchronous Transmission (back-to-back)