Mitsubishi Motors DS5000TK User Manual

Page 122

Advertising
background image

USER’S GUIDE

050396 121/173

122

This formula solves as :

TH1

+

256

*

2

SMOD

32 * 12 t

CLK

* BaudRate

For 9600 = Baud rate, TH1 = FDh with SMOD = 0.

To create 19,200 baud, the SMOD bit should be set to a
logic 1 with the same value for TH1. SMOD has the
effect of doubling the baud rate for any time out value.

The value for TH1 and SMOD have been determined.
The only remaining task is to configure the Timer 1 for
8–bit auto reload operation. This will cause the timer to
start counting from the TH1 value after each time out.
The TMOD register is set as follows:

TH1 – 8Dh
D7

D6

D5

D4

D3

D2

D1

D0

1

1

1

1

1

1

0

1

PCON – 87h
SMOD

POR

PFW

WTR

EPFW

EWT

STOP

IDL

0

X

X

X

X

X

X

X

TMOD – 89h
GATE

C/T

M1

M0

GATE

C/T

M1

M0

0

0

1

0

X

X

X

X

As shown in the TCON description, setting M1 = 1 and
M0 = 0 selects Timer 1 mode 2 which is the 8–bit auto–
reload mode. In this example, Timer 0 is not used, so the
lower four bits of TMOD are unused. Therefore the
TMOD register can be written with 00100000b or 20h.

The remaining step is to enable the timer. Once this is
done, the baud rate generator will be in operation and
serial I/O can be performed. The TCON register is used
to enable the timers as shown below. The TR1 bit is set
to a logic 1 to enable the Timer 1 function. Writing a
01000000b or 40h to TCON will do this.

TCON – 88h
TF1

TR1

TF0

TR0

IE1

IT1

IE0

IT0

0

1

0

0

0

0

0

0

In summary the following SFRs are configured to enable
the serial port for 9600 baud asynchronous operation:

TH1

FDh

SCON

50h

IE

90h

IP

10h

TMOD

20h

TCON

40h

PCON

00h (SMOD=0)

To set up the Serial Port for 19,200 baud, the only differ-
ence is that the SMOD bit at PCON.7 is set. Therefore,
writing 80h to PCON will accomplish this.

The software that configures the serial port can be sim-
ply seven move instruction the configure the SFRs men-
tioned above to the value as shown. This example will
show this code in the context of performing the applica-
tion described at the beginning of this note.

The application example described moving 256 bytes of
data from memory to the serial port, then receiving a
confirmation code of 0A5h. The memory will be
assumed to be located in the MOVX RAM beginning at
the Partition address. For this example, the Partition will
be 4000h and the microcontroller will be a DS5000.
Using a DS5001/2 would change the value written to the
MCON to configure the Partition.

Advertising
This manual is related to the following products: