USER'S GUIDE

This formula solves as :

 

 

 

The value for TH1 and SMOD have been determined.

 

 

 

 

 

 

2SMOD

 

The only remaining task is to configure the Timer 1 for

TH1 + 256 *

 

 

 

 

 

8±bit auto reload operation. This will cause the timer to

32 * 12 t

CLK

* BaudRate

 

 

 

 

 

 

 

 

 

start counting from the TH1 value after each time out.

 

 

 

 

 

 

 

 

 

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

The TMOD register is set as follows:

 

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.

 

 

 

 

 

 

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.

TCON ± 88h

 

 

 

TF1

TR1

TF0

TR0

0

1

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 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.

IE1

IT1

IE0

IT0

0

0

0

0

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.

050396 121/173

122

Page 122
Image 122
Mitsubishi DS907x SIP, DS5000TK manual Smod POR PFW WTR Epfw EWT Stop IDL, TF1 TR1 TF0 TR0, IE1 IT1 IE0