USER'S GUIDE

Timers

 

 

 

tively. Shown here is an example of Timer and Serial

The microprocessor disables timer activity (excluding

Port setup. In this example, Timer 0 is set up to generate

the Watchdog) and serial port communication on a re-

a 10 ms interrupt. Timer 1 is setup to generate 9600

set. Therefore, each timer must be setup and enabled

baud for the serial port. The serial port is set up for

as part of the reset routine. The serial port mode must

asynchronous communication with a PC (mode 1). A

also be initialized if used. This is covered in detail in the

crystal frequency of 11.0592 MHz is assumed.

User's Guide section on Timers and Serial I/O respec-

 

ORG

00h

 

 

 

SJMP

Start

 

 

 

Org

30h

 

 

 

Start :

 

 

 

 

SETB

PS

 

;Set Serial Port Interrupt to High Priority

SETB

ES

 

;Enable Serial Port Interrupt

SETB

ET0

 

;Enable Timer 0 Interrupt

MOV

TMOD,

#00100001b

;Select Timer 1 mode 2 ± 8 bit auto±reload,

 

 

 

;

Timer 0 mode 1 ± 16 bit manual reload

MOV

TH1,

#0FDh

;Setup 9600 baud

MOV

TL1,

#00h

; º º

 

MOV

TH0,

#0DBh

;Select a 10 ms count. 9216 counts = 10 ms

MOV

TL0,

#0FFh

; 9216d counts = 2400h counts (FFFFh±2400h =

 

 

 

; DBFFh)

 

 

 

; Timer 0 ISR must reload DBFFh manually

MOV

SCON,

#01010011b

;Select Serial Port mode 1,

 

 

 

; TXD and RXD interrupts active

MOV

TCON,

#01010000b

;Enable the operation of both Timers

SETB

EA

 

;Globally enable interrupts

Protection

The microprocessor provides protection from transients through a built in power±fail/power±on reset and Watch- dog Timer. Each of these functions should be initialized

by the user as part of the reset routine. The following code demonstrates the set up for a user that will support the Watchdog function.

TA EQU 0C7h

ORG 00h

SJMP Start

Org 30h

Start :

MOV

TA,

#0AAh

;Timed

 

MOV

TA,

#55h

; Access

 

ORL

IP,

#80h

;Set RWT

to restart the Watchdog Timer

MOV

TA,

#0AAh

;Timed

 

MOV

TA,

#55h

; Access

 

ORL

PCON,

#44h

;Set POR

(PCON.6) bit for power on reset detect

; and enable Watchdog Timer by setting EWT (PCON.2)

050396 87/173

88

Page 88
Image 88
Mitsubishi DS907x SIP, DS5000TK manual Timers, Protection, Tively. Shown here is an example of Timer and Serial