beautypg.com

3 mode 2, 4 mode 3, 2 serial port initialization – Maxim Integrated High-Speed Microcontroller User Manual

Page 137: Serial i/o, Erial, Ummary, Mode 0, Mode 1

background image

High-Speed Microcontroller User’s Guide

Rev: 062210

137 of 176

12.1.3

Mode 2

This mode is an asynchronous mode that transmits a total of 11 bits. These include 1 start bit, 8 data bits,
a programmable ninth bit, and 1 stop bit. The ninth bit is determined by the value in TB8 (

SCON0

.3 or

SCON1

.3) for transmission. When the ninth bit is received, it is stored in RB8 (

SCON0

.2 or

SCON1

.2).

The ninth bit can be a parity value by moving the P bit (PSW.0) to TB8.

The baud rate for Mode 2 is a function of the oscillator frequency. It is either the oscillator input divided
by 32 or 64 as programmed by the SMOD bit in the

PCON

register. Mode 2 operation is identical to the

standard 80C32.

12.1.4

Mode 3

This mode has the same functionality as Mode 2, but generates baud rates like Mode 1. That is, this mode
transmits 11 bits, but generates baud rates via the timers. Like Mode 1, either Timer 1 or 2 can be used for
Serial Port 0 and Timer 1 can be used for Serial Port 1. Mode 3 operation is identical to the standard
80C32 when Timers 1 or 2 use the default divide-by-12 of the oscillator.

12.2 Serial Port Initialization

In order to use the UART function(s), the serial port must be initialized. This involves selecting the mode
and time base, then initializing the baud-rate generator if necessary. Serial communication is then
available. Once the baud-rate generator is running, the UART can receive data.

In Mode 0, the high-speed microcontroller provides the clock. Serial reception is initiated by setting the
RI bit to a logic 0 and REN to a logic 1. This will generate a clock on the TXD pin and shift in the 8 bits
on the RXD pin. In the other modes, setting the REN bit to logic 1 will allow serial reception. The
external device must actually initiate it by sending a start bit. In any mode, serial transmission is initiated
by writing to either the

SBUF0

or

SBUF1

location.


Most of the serial port controls are provided by the

SCON0

and

SCON1

registers. For convenience, these

are provided in

Table 12-A

. In addition, other control bits that influence the Serial Port operation are also

summarized below.

Table 12-A. Serial I/O Modes

MODE

SYNCH/ASYNCH

BAUD

CLOCK*

DATA

BITS

START/STOP

9TH BIT FUNCTION

0

Synch

4 or 12t

CLK

8

None

None

1

Asynch

Timer 1 or 2**

8

1 start, 1 stop

None

2 Asynch 32

or

64t

CLK

9

1 start, 1 stop

0, 1, parity

3

Asynch

Timer 1 or 2**

9

1 start, 1 stop

0, 1, parity


*The use of PMM1 or PMM2 will affect the baud clock.

**

Timer 2 available for Serial Port 0 only.