User`s manual

PK2100
4-10 s System Development
The serial ports may be polled or interrupt-driven. A polling driver tests
the ready flags (TDRE and RDRF) until a ready condition appears (transmit-
ter data register empty or receiver data register full). If an error condition
occurs on receive, the routine must clear the error flags and take any
appropriate action. If the CTS line is used for flow control, transmission
of data is automatically stopped when CTS goes high because the TDRE
flag is disabled. This prevents the driver from transmitting more charac-
ters, because it thinks the transmitter is not ready. The transmitter will
still function with CTS high, but care must be exercised since TDRE is
not available to synchronize the loading of the data register (TDR).
An interrupt-driven driver works with the program enabling the receiver
interrupt as long as it wants to receive characters. The transmitter
interrupt is enabled only while characters are waiting in the output buffer.
When an interrupt occurs, the interrupt routine must determine the cause:
receiver data register full, transmitter data register empty, receiver error,
or DCD0 pin high (channel 0 only). None of these interrupts is edge-
triggered. Another interrupt will occur immediately, if the interrupts are
re-enabled without disabling the condition causing the interrupt. The
signal DCD0 is especially treacherous because it cannot be disabled
when the receive interrupts are on. In most designs, the DCD0 line
should be connected directly to ground, thus taking it out of the picture.