VII - 69
Chapter 7
16-bit Timers
Cascade Connection
7-13-2
Setup Example (Timer Operation)
nCascade Connection Timer Setup Example (Timer 7+ Timer 8)
Setting example of timer function that an interrupt is constantly generated by cascade connection of
timer 7 and timer 8, as a 32-bit timer is shown. An interrupt is generated in every 100000 cycles (40 ms)
by selecting source clock to fs/4 (fosc=20 MHz).
An example setup procedure, with a description of each step is shown below.
(1)
Set the TM7EN flag of the timer 7 mode
register (TM7MD1) to "0", the TM8EN flag of
the timer 8 mode register to "0" to stop timer 7
and timer 8 counting.
(2)
Set the TM7BCR flag of TM7MD2 register to
"1" to select compare match as a clear source
of the binary counter.
(3)
Set the TM7ICEN flag of the TM7MD2 register
to "0", the TM7OUT1-0 flag of TM7MD3
register to "00" to select normal timer
operation.
(4)
Set the TM8CAS flag of the TM8MD1 register
to "1" to connect timer 7 and timer 8 in
cascade connection.
(5)
Select fs as the clock source by the
TM7CK1-0 flag of the TM7MD1 register.
Also, select 1/4 dividing of fs as the count
clock source by the TM7PS1-0 flag.
(6)
Set the timer 7 preset register 1 (TM7PR1) and
timer 8 preset register 1 (TM8PR1) to the
interrupt generation cycle (100000 cycles - 1).
At that time, the same values as the preset
registers are loaded to the timer compare
register1 (TM7OC1) and timer 8 compare
register 1(TM8OC1), and the binary
counters are initialized to x'0000'.
Setup Procedure
(1)
Stop the counter.
TM7MD1 (x'3F78')
bp4
:TM7EN
= 0
TM8MD1 (x'3F88')
bp7
:TM8EN
= 0
(2)
Select the condition for timer clear.
TM7MD2 (x'3F79')
bp5
:TM7BCR
= 1
(3)
Select the normal lower timer
operation.
TM7MD2 (x'3F79')
bp2
:TM7ICEN
= 0
TM7MD3 (x'3F6C')
bp1-0
:TM7OUT1-0= 00
(4)
Set the cascade connection.
TM8MD1 (x'3F88')
bp6
:TM8CAS
= 1
(5)
Select the count clock source.
TM7MD1 (x'3F78')
bp1-0
:TM7CK1-0 = 01
bp3-2
:TM7PS1-0 = 10
(6)
Set the interrupt generation cycle.
TM7PR1(x'3F75', x'3F74')=x'869F'
TM8PR1(x'3F85', x'3F84')=x'0001'
Description