20.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 20-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 implementations require 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 20-14 shows an example IrDA waveform.

Figure 20-14. IrDA® Encoding/Decoding When TXPOL = 1

To configure the UART for IrDA mode, the following sequence is used:

  1. Configure the clock input and baud rate as detailed in Clocking and Baud Rate Configuration.
  2. Configure IrDA mode by writing ‘0b1110’ to the MODE[3:0] bits.
  3. Set the TXPOL and RXPOL bits.
  4. Configure the interrupt watermark using the TXWM[2:0] and RXWM[2:0] bits.
  5. Set the ON bit.
  6. Set the RXEN and TXEN bits.

In IrDA mode, the UART functions similar to Asynchronous mode regarding errors, events and interrupts.