On-Chip Peripheral Components
C513AO
User’s Manual
6-30
05.99
6.3
Serial Interface (USART)
The serial port is a full duplex port capable of simultaneous transmit and receive functions. It is also
receive-buffered; it can commence reception of a second byte before a previously-received byte
has been read from the receive register. (However, if the first byte has not been read before
reception of the second byte is complete, one of the bytes will be lost). The serial port receive and
transmit registers are accessed at special function register SBUF. Writing to SBUF loads the
transmit register, and reading SBUF accesses a physically separate receive register.
The serial port can operate in 4 modes (one synchronous and three asynchronous):
Mode 0, Shift Register (Synchronous) Mode:
Serial data enters and exits through RXD. TXD outputs the shift clock. 8 data bits are transmitted/
received with the Least Significant Bit (LSB) first. The baudrate is fixed at
1
/
12
th of the oscillator
frequency.
Mode 1, 8-Bit USART, Variable Baudrate:
Ten bits are transmitted through TXD or received through RXD: a start bit (0), 8 data bits (LSB first),
and a stop bit (1). On receive, the stop bit goes into RB8 in special function register SCON. The
baudrate in Mode 1 is variable.
Mode 2, 9-Bit USART, Fixed Baudrate:
Eleven bits are transmitted through TXD or received through RXD: a start bit (0), 8 data bits (LSB
first), a programmable 9th data bit, and a stop bit (1). On transmit, the 9th data bit (TB8 in SCON)
can be assigned to the value of “0” or “1”. Or, for example, the parity bit (P, in the PSW) could be
moved into TB8. On receive, the 9th data bit goes into RB8 in special function register SCON, while
the stop bit is ignored. The baudrate in Mode 2 is programmable to either
1
/
32
nd or
1
/
64
th of the
oscillator frequency.
Mode 3, 9-Bit USART, Variable Baudrate:
Eleven bits are transmitted through TXD or received through RXD: a start bit (0), 8 data bits (LSB
first), a programmable 9th data bit, and a stop bit (1). In fact, Mode 3 is the same as Mode 2 in all
respects except the baudrate. The baudrate in Mode 3 is variable.
In all four modes, transmission is initiated by any instruction that uses SBUF as a destination
register. Reception is initiated in Mode 0 by the condition RI = 0 and REN = 1. Reception is initiated
in the other modes by the incoming start bit if REN = 1.
In all four modes, transmission is initiated by any instruction that uses SBUF as a destination
register. Reception is initiated in Mode 0 by the condition RI = 0 and REN = 1. Reception is initiated
in the other modes by the incoming start bit if REN = 1. The serial interface also provides interrupt
requests when transmission or reception of a frame is completed. The corresponding interrupt
request flags for the serial interface are TI or RI, respectively. See Chapter 7 for more details about
the interrupt structure. The interrupt request flags, TI and RI, can also be used for polling the serial
interface if the serial interrupt is not to be used (that is, serial interrupt is not enabled).