21.4.2.3 IrDA®
The UART supports the infrared IrDA protocol with a built-in
encoder/decoder, so an external codec is not required. Each bit time is divided into 16
clock cycles; therefore, the clock prescaler BRGS is forced to ‘0’, and
Equation 21-1 is used for the baud rate calculation. The IrDA encoding/decoding
consists of the following translations:
- A value of ‘
1’ is translated to ‘0’ for all of the 16 clocks. - A value of ‘
0’ is translated to ‘0’ for the first seven clocks, ‘1’ for the next three, and ‘0’ for the remaining six clocks.
To enable IrDA, set MODE[3:0] = 0b1110 (UxCON[3:0]).
Typical IrDA requires an active-low Idle; therefore, it is recommended to operate the
UART with both TXPOL and RXPOL set to ‘1’. This allows the UxTX and
UxRX pins to connect directly to an infrared transceiver. Figure 21-14 shows an example of an IrDA waveform.
To configure the UART for IrDA mode, the following sequence is used:
- Configure the clock input and baud rate as detailed in Clocking and Baud Rate Configuration.
- Configure IrDA mode by writing ‘
0b1110’ to the MODE[3:0] bits. - Set the TXPOL and RXPOL bits.
- Configure the interrupt watermark using the TXWM[2:0] and RXWM[2:0] bits.
- Set the ON bit.
- Set the RXEN and TXEN bits.
In IrDA mode, the UART functions similarly to Asynchronous mode regarding errors, events and interrupts.
