SN8P2200 Series
USB 1.1 Low-Speed 8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 68
Version 1.7
6.11
T2 INTERRUPT OPERATION
When the T2C counter stops by T2 pulse width measurement finished, the T2IRQ will be set to “1” no matter the T2IEN
is enable or disable. If the T2IEN and the trigger event T2IRQ is set to be “1”. As the result, the system will execute
the interrupt vector. If the T2IEN = 0, the trigger event T2IRQ is still set to be “1”. Moreover, the system won’t execute
interrupt vector even when the T2IEN is set to be “1”. Users need to be cautious with the operation under
multi-interrupt situation.
¾
Example: T2 interrupt request setup.
B0BCLR
FT2IEN
; Disable T2 interrupt service
B0BCLR
FT2ENB
; Disable T2 timer
MOV
A,
#20H
;
B0MOV
T2M, A
; Set T2 clock = Fcpu / 64 and falling edge trigger.
CLR
T2C
B0BSET
FT2IEN
; Enable T2 interrupt service
B0BCLR
FT2IRQ
; Clear T2 interrupt request flag
B0BSET
FT2ENB
; Enable T2 timer
B0BSET
FGIE
; Enable GIE
¾
Example: T2 interrupt service routine.
ORG
8
; Interrupt vector
JMP
INT_SERVICE
INT_SERVICE:
PUSH
; Push routine to save ACC and PFLAG to buffers.
B0BTS1
FT2IRQ
; Check T2IRQ
JMP
EXIT_INT
; T2IRQ = 0, exit interrupt vector
B0BCLR
FT2IRQ
; Reset T2IRQ
B0MOV A,
T2C
B0MOV
T2CBUF, A
; Save pulse width.
CLR T2C
…
; T2 interrupt service routine
…
EXIT_INT:
POP
; Pop routine to load ACC and PFLAG from buffers.
RETI
; Exit interrupt vector