Programming Example Using An Interrupt-Driven Routine - Intel 8XC196NT User Manual

Table of Contents

Advertisement

The receiver checks for a valid stop bit. Unless a stop bit is found within the appropriate time, the
framing error (FE) bit in the SP_STATUS register is set. When the stop bit is detected, the data
in the receive shift register is loaded into SBUF_RX and the receive interrupt (RI) flag is set. If
this happens before the previous byte in SBUF_RX is read, the overrun error (OE) bit is set.
SBUF_RX always contains the latest byte received; it is never a combination of the last two bytes.
The receive interrupt (RI) flag indicates whether an incoming data byte has been received. The
transmit interrupt (TI) flag indicates whether a data byte has finished transmitting. These flags
also set the corresponding bits in the interrupt pending register. A reception or transmission sets
the RI or TI flag in SP_STATUS and the corresponding interrupt pending bit. However, a soft-
ware write to the RI or TI flag in SP_STATUS has no effect on the interrupt pending bits and does
not cause an interrupt. Similarly, reading SP_STATUS clears the RI and TI flags, but does not
clear the corresponding interrupt pending bits. The RI and TI flags in the SP_STATUS and the
corresponding interrupt pending bits can be set even if the RI and TI interrupts are masked.
The transmitter empty (TXE) bit is set if SBUF_TX and its buffer are empty and ready to accept
up to two bytes. TXE is cleared as soon as a byte is written to SBUF_TX. One byte may be written
if TI alone is set. By definition, if TXE has just been set, a transmission has completed and TI is
set.
The received parity error (RPE) flag or the received bit 8 (RB8) flag applies for parity enabled or
disabled, respectively. If parity is enabled, RPE is set if a parity error is detected. If parity is dis-
abled, RB8 is the ninth data bit received in modes 2 and 3.
7.5

PROGRAMMING EXAMPLE USING AN INTERRUPT-DRIVEN ROUTINE

This programming example is an interrupt-driven "putchar" and "getchar" routine that allows you
to set the size of the transmit and receive buffers, the baud rate, and the operating frequency.
#pragma model(kr)
#pragma interrupt(receive=28,transmit=27)
#ifdef EVAL_BOARD
/*
Reserve the 9 bytes required by eval board
char reserve[9];
#pragma locate(reserve=0x30)
#else
/*
Initialize the chip configuration bytes
const unsigned int ccr[2] = {0x20FF,0x20DE};
#pragma locate (ccr = 0x2018)
#endif
SERIAL I/O (SIO) PORT
*/
*/
7-13

Advertisement

Table of Contents
loading

Table of Contents