SN8P26L38
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 73
Version 1.5
6.11
COMPARATOR INTERRUPT OPERATION (CMP0, CMP1)
Sonix provides 2 sets comparator with interrupt function in the micro-controller. The comparator interrupt trigger edge
direction is the rising edge of comparator output . When the comparator output status transition occurs, the comparator
interrupt request flag will be set to
“1” no matter the comparator interrupt control bit status. The comparator interrupt
flag
doesn’t active only when comparator control bit is disabled. When comparator interrupt control bit is enabled and
comparator interrupt edge trigger is occurring, the program counter will jump to the interrupt vector (ORG 8) and
execute interrupt service routine.
09CH
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
CMP0M
CM0EN
CM0IEN
CM0IRQ
CM0OEN
CM0REF
CM0OUT
CMS1
CMS0
Read/Write
R/W
R/W
R/W
R/W
R/W
R
R/W
R/W
After Reset
0
0
0
0
0
0
0
0
Bit 6
CM0IEN:
Comparator 0 interrupt function control bit.
0 = Disable.
1 = Enable.
Bit 5
CM0IRQ:
Comparator 0 interrupt request bit.
0 = Non comparator interrupt request.
1 = Announce comparator interrupt request.
09DH
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
CMP1M
CM1EN
CM1IEN
CM1IRQ
CM1OEN
CM1REF
CM1OUT
-
-
Read/Write
R/W
R/W
R/W
R/W
R/W
R
-
-
After Reset
0
0
0
0
0
0
-
-
Bit 6
CM1IEN:
Comparator 1 interrupt function control bit.
0 = Disable.
1 = Enable.
Bit 5
CM1IRQ:
Comparator 1 interrupt request bit.
0 = Non comparator interrupt request.
1 = Announce comparator interrupt request.
Example: Setup comparator 0 interrupt request.
B0BSET
FCM0IEN
; Enable comparator 0 interrupt service
B0BCLR
FCM0IRQ
; Clear comparator 0 interrupt request flag
B0BSET
FCM0EN
; Enable comparator 0.
B0BSET
FGIE
; Enable GIE
Example: Comparator 0 interrupt service routine.
ORG
8
; Interrupt vector
JMP
INT_SERVICE
INT_SERVICE:
…
; Push routine to save ACC and PFLAG to buffers.
B0BTS1
FCM0IRQ
; Check CM0IRQ
JMP
EXIT_INT
; CM0IRQ = 0, exit interrupt vector
B0BCLR
FCM0IRQ
; Reset CM0IRQ
…
; Comparator 0 interrupt service routine
EXIT_INT:
…
; Pop routine to load ACC and PFLAG from buffers.
RETI
; Exit interrupt vector