Mitsubishi Motors DS5000TK User Manual

Page 120

Advertising
background image

USER’S GUIDE

050396 119/173

120

APPLICATION: SERIAL PORT
INITIALIZATION

The serial port can provide either synchronous or
asynchronous serial communication. This note demon-
strates how to initialize the serial port and includes an
example showing how to perform asynchronous com-
munication with a PC COM port.

A typical goal of microcontroller to PC communication is
to transfer stored data from the nonvolatile RAM. This
example will show how to move 256 bytes from NV RAM
to the PC via the serial port. Once the 256 bytes have
been received by the PC, it will send confirmation. For
this example, the confirmation code will be A5h. The
Microcontroller will run at 11.0592 MHz, a common crys-

tal choice. This example will demonstrate both 9600 and
19,200 bps. A typical application has some form of error
checking built into the data, so no parity is required. This
code will therefore run at 8N1 or 8 bits, no parity, 1 stop
bit. This is a common selection for PC terminal emulator
software. Thus the setup summary is as follows:

Communication type :

Asynchronous

Baud Rate :

9600, 19200

Bits per word :

8

Stop bits :

1

As shown in the following table, this most closely corre-
sponds to Serial Mode 1.

SERIAL I/O OPERATING MODES

MODE

SYNC/ASYNC

BAUD CLOCK

DATA BITS

START/STOP

9TH DATA BIT

FUNCTION

MODE 0

SYNC

12 t

CLK

8

None

None

MODE 1

ASYNC

Timer 1
Overflow

8

1 Start

1 Stop

None

MODE 2

ASYNC

32 t

CLK

or

64 t

CLK

9

1 Start

1 Stop

0, 1, or parity

MODE 3

ASYNC

Timer 1
Overflow

9

1 Start

1 Stop

0, 1, or parity

The Serial Port is controlled by the SCON register.
Serial Interrupts will also be used. These are controlled
by IE and IP. The setup for each SFR is shown below. In
addition, Mode 1 is associated with Timer 1, which is
controlled by TCON and TMOD.

Mode 1 is selected using the SCON register. The table
from the SCON register shown below indicates that
Mode 1 is selected by choosing the value SM0 = 0 and
SM1 = 1.

SMO

SM1

MODE

FUNCTION

WORD LENGTH

BAUD CLOCK

0

0

Mode 0

Synchronous

8 bits

12 t

CLK

0

1

Mode 1

Asynchronous

10 bits

Timer 1 Overflow

1

0

Mode 2

Asynchronous

11 bits

32 or 64 t

CLK

1

1

Mode 3

Asynchronous

11 bits

Timer 1 Overflow

Advertising
This manual is related to the following products: