Mitsubishi Motors DS5000TK User Manual

Page 88

Advertising
background image

USER’S GUIDE

050396 87/173

88

Timers

The microprocessor disables timer activity (excluding
the Watchdog) and serial port communication on a re-
set. Therefore, each timer must be setup and enabled
as part of the reset routine. The serial port mode must
also be initialized if used. This is covered in detail in the
User’s Guide section on Timers and Serial I/O respec-

tively. Shown here is an example of Timer and Serial
Port setup. In this example, Timer 0 is set up to generate
a 10 ms interrupt. Timer 1 is setup to generate 9600
baud for the serial port. The serial port is set up for
asynchronous communication with a PC (mode 1). A
crystal frequency of 11.0592 MHz is assumed.

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)

Advertising
This manual is related to the following products: