AN201
Rev 1.5 | 74/91
www.cmostek.com
11 Comparator
2 analog comparators are integrated in the chip. As the function pins of the comparator 2 are used for the RF serial control bus at
the same time, the 2 comparators cannot be used.
It should be noted that, when reading a port register, the software reading value is 0 if the pin is configured as an analog signal
pin. Even when the pin is set as a digital input pin, the comparator will still regard the pin will input an analog signal th us output
the corresponding result. If the pin is set as a digital input, however the actual voltage on this pin is still an analog voltage, it may
cause the input buffer circuit to consume more current than that in the specifications.
The analog comparator supports 8 configuration modes. They are selected by the CM<2:0> bit of the CMCON0 register.
However, only 2 states are supported as shown in the below figure, since the functional pins are used in the RF serial control bus.
Comparator reset (after POR)
CM<2:0> = 0b000
+
-
+
-
Off
Off
C1IN+
C1IN-
C2IN+
C2IN-
A
A
A
A
Comparator switched off (with the lowest power)
CM<2:0> = 0b111
+
-
+
-
C1IN+
C1IN-
C2IN+
C2IN-
Off
Off
I/O
I/O
I/O
I/O
Figure 25. 2 Configuration Modes of Analog Comparator
Analog function (A): the digital input buffer is disabled.
Digital function (D): the comparator digital output will override the other functions in the pin
Normal port function (I/O): it is independent of the comparator.
When the word A is marked on the port, the current pin states of the TRIS bit of the I/O control register will return to 0 per read
operation. The TRIS bit, a bit corresponding to the analog input pin, should be set to1 to close its digital output drive circuit.
When the word D is marked on the port, users should set the corresponding TRIS bit to 0 to open the digital output driver circuit.
In addition, the comparator interrupt should be disabled during the comparator configuration switching to avoid unexpected
miss-triggered events.