SN8P2740 Series
ADC, OP-amp, Comparator 8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 100
Version 2.0
10.5 COMPARATOR APPLICATION NOTICE
The comparator is to compares the positive voltage and negative voltage to output result. The positive and negative
sources are analog signal. In hardware application circuit, the comparator input pins must be connected a 0.1uF
comparator to reduce power noise and make the input signal more stable. The application circuit is as following.
MCU
CMnN
0.1uF
CMnP
0.1uF
CMnO
Comparator
Output
Comparator
Negative Input
Comparator
Positive Input
10.6 COMPARATOR 1 OPERATION EXPLAME
COMPARATOR 1 CONFIGURATION:
; Reset Comparator 1.
CLR
CM1M
; Clear CM1M register.
; Set Comparator 1 positive terminal.
MOV
A, #00000
nnn
b
; Set CM1RS[2:0] for comparator positive terminal.
B0MOV
CM1M, A
; Set Comparator 1 function mode.
B0BCLR
FCM1SF
; Normal comparator mode.
; or
B0BSET
FCM1SF
; Special function mode.
; Set Comparator 1 output pin.
B0BCLR
FCM1OEN
; Disable comparator 1 output pin.
; or
B0BSET
FCM1OEN
; Enable comparator 1 output pin.
; Set Comparator 1 interrupt trigger edge.
B0BCLR
FCM1G
; Falling edge.
; or
B0BSET
FCM1G
; Rising edge.
; Set Comparator 1 output de-bounce.
B0MOV
A, CMDB0
; Set CM1D[3:0] for comparator output de-bounce.
AND
A, #
0000
1111b
OR
A, #
nnnn
0000b
B0MOV
CMDB0, A
; Clear CM1IRQ
B0BCLR
FCM1IRQ
; Enable Comparator 1 and interrupt function.
B0BSET
FCM1IEN
; Enable Comparator 1 interrupt function.
B0BSET
FCM1EN
; Enable Comparator 1.