148
µ
PD17062
12.5.1 Example of Using a Timer Based on a Timer Interrupt
An example follows.
Example
BR AAA ; Branches to AAA.
TIMER: ; Program address 0003H
ADD M1, #0001B ; Add 1 to M1.
SKT1 CY ; Tests the CY flag.
BR BBB ; Returns if no carry is generated.
Process A
BBB:
EI
RETI
AAA:
INITFLG NOT BTM0ZX, NOT BTM0CK2, NOT BTM0CK1, NOT BTM0CK0
; Built-in macro
; Specifies the timer interrupt pulse as 5 ms.
MOV M1, #0000B ; Clears the content of M1 to 0.
SET1 IPBTM0 ; Enables a timer interrupt.
EI ; Enables all types of interrupts.
LOOP:
Process B
BR LOOP
This program performs process A at every 80 ms.
At this point, note the following: Accepting an interrupt request causes a DI state automatically, and the
IRQBTM0 flag is set to 1 even in the DI state.
In other words, if process A takes 5 ms or longer, an interrupt request will be accepted immediately when
a return is made by a RETI instruction, thus disabling process B from being performed.