Panasonic MN101C77C User Manual

Page of 544
VI - 41
Chapter 6    8-bit Timers
Cascade Connection
6-10-2
Setup Example
„
Cascade Connection Timer Setup Example (Timer 0 + Timer 1)
Setting example of timer function that an interrupt is constantly generated by cascade connection of
timer 0 and timer 1, as a 16-bit timer is shown. An interrupt is generated in every 2500 cycles (1 ms) by
selecting source clock to fs/4 (fosc=20 MHz at operation).
An example setup procedure, with a description of each step is shown below.
(1)
Set the TM0EN flag of the timer 0 mode
register (TM0MD) to "0", the TM1EN flag of the
timer 1 mode register to "0" to stop timer 0 and
timer 1 counting.
(2)
Set both of the TM0PWM flag and TM0MOD
flag of the TM0MD register to "0" to select the
normal operation of timer 0.
(3)
Set the TM1CAS flag of the TM1MD register to
"1" to connect timer 1 and timer 0 in cascade
connection.
(4)
Set the clock source to prescaler output by
the TM0CK2-0 flag of the TM0MD register.
(5)
Set the prescaler output to fs/4 by the
TM0PSC1-0, TM0BAS flag of the timer 0
prescaler selection register (CK0MD).
Also, set the PSCEN flag of the prescaler
control register (PSCMD) to "1" to enable the
prescaler counting.
(6)
Set the timer 1 compare register + timer 0
compare register (TM1OC + TM0OC) to the
interrupt generation cycle (x'09C3' : 2500
cycles - 1).
At that time, timer 1 binary counter + timer 0
binary counter (TM1BC + TM0BC) are
initialized to x'0000'.
Setup Procedure
(1)
Stop the counter.
TM0MD (x'3F54')
bp3
:TM0EN
= 0
TM1MD (x'3F55')
bp3
:TM1EN
= 0
(2)
Select the normal operation lower
timer.
TM0MD (x'3F54')
bp4
:TM0PWM = 0
bp5
:TM0MOD
= 0
(3)
Set the cascade connection.
TM1MD (x'3F55')
bp4
:TM1CAS
= 1
(4)
Select the count clock source.
TM0MD (x'3F54')
bp2-0
:TM0CK2-0 = 001
(5)
Select the prescaler output and
enable counting.
CK0MD (x'3F56')
bp2-1
:TM0PSC1-0= 01
bp0
:TM0BAS
= 1
PSCMD (x'3F6F')
bp0
:PSCEN
= 1
(6)
Set the interrupt generation cycle
TMnOC(x'3F53', x'3F52')=x'09C3'
Description