CS452 - Real-Time Programming - Spring 2010

Public Interest Announcements


Lecture 16 - UART Interrupts

FIFO

Why do FIFOs exist in UARTS?

The Big Blunder

To use the FIFO effectively you must be able to turn off the transmitter & receiver independently.

But look at UARTE in UARTxCtrl

The Little Blunder

`It is assumed that various configuration registers for the UART are not written more than once in quick succession, in order to insure proper synchronization of configuration information across the implementation. Such registers include UART1Ctrl and UART1LinCtrlHigh. ... In between the two writes, at least two UARTCLK periods must occur. Under worst case conditions, at least 55 HCLK periods must separate the two writes. The simplest way to due [sic] this is separate the two writes by 55 NOPs.'

Why does this occur?

Why doesn't anybody care?

Interrupts

Five interrupts in the device

  1. Transmit
  2. Receive
  3. Modem status
  4. Receive timeout
  5. Combined

Three inputs to the PIC

  1. Transmit
  2. Receive
  3. Combined

Easy way to use interrupts

Enable only combined; read UART registers to decide what to do.

Think of the receive and transmit parts of the UART as separate state machines

More difficult way to use interrupts

Use combined for COM1, transmit/receive for COM2.

Handy Features

Loopback

Terminal as line analyser.


Implementation

The simplest way to handle the interrupts is to turn on only the combined interrupt and then look at the registers of the device.

To identify the current interrupt

Read UARTxIntIDIntClr at 0x800[bc]001c

When service is required

Transmitting

  1. Initialization
  2. When bytes arrive to transmit
  3. On transmit interrupt
  4. On modem status interrupt

Receiving

  1. Getting started
  2. Receive interrupt

Receive Time Out interrupt

Read from FIFO until empty


Return to: