mpc82g516a Megawin Technology, mpc82g516a Datasheet - Page 51

no-image

mpc82g516a

Manufacturer Part Number
mpc82g516a
Description
8-bit Microcontroller
Manufacturer
Megawin Technology
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
mpc82g516aE
Manufacturer:
MEGAWIN
Quantity:
1 200
Part Number:
mpc82g516aF
Manufacturer:
MEGAWIN
Quantity:
20 000
12 Serial Port
12.1 Standard UART Operation
The serial port is full-duplex, meaning it can transmit and receive simultaneously. It is also receive-buffered,
meaning it can commence reception of a second byte before a previously received byte has been read from the
register. (However, if the first byte still hasn’t been read by the time reception of the second byte is complete, one
of the bytes will be lost.) The serial port receive and transmit registers are both accessed at special function
register SBUF. Writing to SBUF loads the transmit register, and reading from SBUF accesses a physically
separate receive register.
The serial port can operate in 4 modes: Mode 0 provides synchronous communication while Modes 1, 2, and 3
provide asynchronous communication. The asynchronous communication operates as a full-duplex Universal
Asynchronous Receiver and Transmitter (UART), which can transmit and receive simultaneously and at different
baud rates.
Mode 0: 8 data bits (LSB first) are transmitted or received through RXD. TXD always outputs the shift clock. The
baud rate is fixed at 1/12 the system clock frequency, i.e., Fosc/12.
Mode 1: 10 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 baud rate is variable.
Mode 2: 11 bits are transmitted through TXD or received through RXD: 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 register) can be
assigned the value of 0 or 1. Or, for example, the parity bit (P, in PSW register) could be moved into TB8. On
receive, the 9th data bit goes into RB8 in SCON register, while the stop bit is ignored. The baud rate can be
configured to 1/32 or 1/64 the system clock frequency, i.e., Fosc/64 or Fosc/32.
Mode 3: 11 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 baud
rate. The baud rate in Mode 3 is variable.
In all four modes, transmission is initiated by any instruction that uses SBUF as a destination register. In Mode 0,
reception is initiated by the condition RI=0 and REN=1. In the other modes, reception is initiated by the incoming
start bit if REN=1.
12.1.1 Multiprocessor Communications
Modes 2 and 3 have a special provision for multiprocessor communications. In these two modes, 9 data bits are
received. The 9th bit goes into RB8. Then comes a stop bit. The port can be programmed such that when the
stop bit is received, the serial port interrupt will be activated only if RB8=1. This feature is enabled by setting bit
SM2 (in SCON register). A way to use this feature in multiprocessor systems is as follows:
When the master processor wants to transmit a block of data to one of several slaves, it first sends out an
address byte which identifies the target slave. An address byte differs from a data byte in that the 9th bit is 1 in an
address byte and 0 in a data byte. With SM2=1, no slave will be interrupted by a data byte. An address byte,
however, will interrupt all slaves, so that each slave can examine the received byte and check if it is being
addressed. The addressed slave will clear its SM2 bit and prepare to receive the data bytes that will be coming.
The slaves that weren’t being addressed leave their SM2 set and go on about their business, ignoring the coming
data bytes.
SM2 has no effect in Mode 0, and in Mode 1 can be used to check the validity of the stop bit. In a Mode 1
reception, if SM2=1, the receive interrupt will not be activated unless a valid stop bit is received.
12.1.2 Serial Port Related Registers
The serial port control and status register is the special function register SCON. This register contains not only
the mode selection bits, but also the 9th data bit for transmit and receive (TB8 and RB8), and the serial port
interrupt bits (TI and RI).
51
MPC82G516A Data Sheet
MEGAWIN

Related parts for mpc82g516a