
μ
PD17016, 17017
106
11.4.2 Function of timer interrupt
The timer interrupt request is issued at the falling edge of a timer interrupt pulse set by the high-order 2 bits
(BTM1CK1 and BTM1CK0 flags) of the timer mode select register (refer to
11.3.3
).
The timer interrupt request corresponds to the IRQTM flag on a one-to-one basis. When the timer interrupt
request is issued, the IRQTM flag is set to “1”.
In other words, the IRQTM flag is set to “1” if the timer interrupt pulse falls.
So that the timer interrupt is acknowledged, the “EI” instruction that enables all the interrupts must be
executed and the timer interrupt must be enabled, in addition to issuance of the interrupt request as explained
in
10. Interrupt
.
The timer interrupt is enabled by setting the IPTM flag to “1”.
Therefore, the timer interrupt is acknowledged if the IRQTM flag is set to “1” when the “EI” instruction is
executed and the IPTM flag is set to “1”.
The IPTM flag is set by a software macro. For the macro that enables or disables an interrupt, refer to
Table
10-2. Software Macros Enabling/Disabling Interrupts
. The IRQTM flag cannot be set by software.
When the timer interrupt is acknowledged, the program execution branches to program memory address
0003H. The IRQTM flag is reset to “0” as soon as the interrupt has been acknowledged.
Figure 11-10 shows the relation between the timer interrupt pulse and IRQTM flag.
Figure 11-10. Relation between Timer Interrupt Pulse and IRQTM Flag
H
L
1
0
1
0
EI
DI
Timer interrupt
pulse
IRQTM
IPTM
INTE
FF
Interrupt pending
period
Interrupt enable period
IRQTM flag is set at
falling edge of timer
interrupt pulse
<1>
Interrupt is not acknowledged
even if EI instruction is executed
because IPTM flag is not set
Timer interrupt is acknowledged as
soon as IPTM flag is set, and interrupt
processing is executed
Acknowledging timer interrupt
and interrupt processing
A point to be noted is that, as shown in point <1> in the above figure, the timer interrupt is acknowledged
when the “EI” instruction is executed next and the IPTM flag is set once the IRQTM flag has been set when the
timer interrupt is disabled by the “DI” instruction or IPTM flag.
In this case, the interrupt request can be cleared by executing a software macro that resets the interrupt
request (refer to
Table 10-1. Software Macros That Reset Interrupt Requests
).
One level of the stack is used when the timer interrupt is acknowledged.
At this time, the contents of the register bank (BANK: address 79H) and the content of the index enable flag
(IXE: bit 0 of address 7FH) are automatically saved.
To return from the interrupt processing routine, use a dedicated instruction “RETI”.
For details, refer to
3. ADDRESS STACK (ASK)
and
10. INTERRUPT
.
The following subsections 11.4.3 and 11.4.4 explain an example of using the timer interrupt and an error of
the timer interrupt.
For the relation between the timer interrupt and the other interrupt (INT
0
pin), refer to
10. INTERRUPT
.