7-15

SERIAL I/O (SIO) PORT
7.4.5 Determining Serial Port StatusYou can read the SPx_STATUS register (Figure 7-8) to determine the status of the serial port.Reading SPx_STATUS clears all bits except TXE. For this reason, we recommend that you copythe contents of the SPx_STATUS register into a shadow register and then execute bit-te st instruc-tions such as JBC and JBS on the shadow register. Otherwise, executing a bit-test instructionclears the flags, so any subsequent bit-test instructions will return false values. You can also readthe interrupt pending register or peripheral interrupt pending register (se e Table 7-2 on page 7-2)to determine the status of the serial port interrupts.
SP
x
_STATUS
x
= 0–1 (8XC196MH)
Address:
Reset State: 1F81H, 1F89H
00H
The serial port status (SP
x
_STATUS) register contains bits that indicate the status of serial port
x
.
7 0
8XC196MH RPE/RB8 RI TI FE TXE OE — —
Bit
Number Bit
Mnemonic Function
7 RPE/RB8 Received Parity Error/Received Bit 8
RPE is set if parity is disabled (S P
x
_CON.2 = 0) and the ninth data bit
received is high.
RB8 is set if parity is enabled (SP
x
_CON.2 = 1) and a parit y error occurred.
Reading SP
x
_STATUS clears this bit.
6 RI Receive Interrupt
This bit is set when the last d ata bit is sampled. Reading SP
x
_STATUS
clears this bit.
5 TI Transmit Interru pt
This bit is set at the begin ning of the stop bit transmi ssion. Reading
SP
x
_STATUS clears this bit.
4 FE Framing Error
This bit is set if a stop bit is not found within the appropriat e perio d of time.
Reading SP
x
_STATUS clears this bit.
3TXESBUF
x
_TX Empty
This bit is set if th e transmit buffer is e mpty and ready to ac cept up to two
bytes. It is cleared when a byte is written to SBUF
x
_TX.
2 OE Overrun Error
This bit is set if data in the receive shift register is loaded into SBUF
x
_RX
before the previous bit is re ad. Reading SP
x
_STATUS clears this bit.
1:0 Reserved; for compat ibility with future devices, write zeros to these bits.

Figure 7-8. Serial Port Status

(SP

x

_STATUS) Register