VII - 19
Chapter 7
16-bit Timers
Operation
7-3
Operation
7-3-1
Operation
The timer operation can constantly generate interrupts.
n16-bit Timer Operation (Timer 7,Timer 8)
The generation cycle of an timer interrupt is set by the clock source selection and the set value of the
compare register 1 (TMnOC1), in advance. When the binary counter (TMnBC) reaches the set value of
the compare register 1, an interrupt is generated at the next count clock. There are 2 sources to be
selected to clear the binary counter; the TMnOC1 compare match and the full count overflow. After the
binary counter is cleared, the counting up is restarted from x'0000'.
Table 7-3-1
16-bit Timer Interrupt Source and Binary Counter Clear Source
(Timer 7, Timer 8)
Timer 7 and timer 8 can generate another set of an independent interrupt (timer 7 and timer 8 compare
register 2 match interrupt) by the set value of the timer 7 and timer 8 compare registers (TM7OC2,
TM8OC2). At the time of the interrupt, the binary counter is cleared as the above setup.
The compare register is double buffer type. So, when the value of the preset register is changed during
the counting, the changed value is stored to the compare register when the binary counter is cleared.
This function can change the compare register value constantly, without disturbing the cycle during timer
operation (Reload function).
When the CPU reads the 16-bit binary counter (TMnBC), the read data is handled in 8-bits
units even if it is a 16-bit MOVW instruction. As a result, it will read the data incorrectly if a
carry from the lower 8 bits to the upper 8 bits occurs during counting operation.
To read the correct value of the 16-bit counting (TMnBC), use the writing program function to
the input capture register (TMnIC). By writing to the TMnIC, the counting data of TMnBC can
be stored to TMnIC to read out the correct counting value during timer operation.
[
Chapter 7-12-1. Operation (p.VII-61) ]
TMnMD2 register
Interrupt source
Binary counter clear source
TMnIRS1 flag
TMnBCR flag
1
TM7nOC1 compare match
TMnOC1 compare match
0
1
TMnOC1 compare match
1
0
TMnOC1 compare match
full count overflow
0
full count overflow