The comparator module consists of two comparators. A comparator is a device which compares two voltages and switches its output to indicate which voltage is greater.
Comparator module uses C.1, C.2, C.5, C.6 pins as analog inputs and C.4, B.3 pins as digital outputs. In some configurations only a subset of these pins is connected to the comparator module. You can use the rest of the pins in other modules or as general purpose
Both comparators can be configured in a variety of ways by GPIO_SET_CMP_CFG command.
A single comparator is shown in Figure 8.1, “Single Comparator”.
There are two analog inputs and one digital output. When the analog input at VIN+ is less than the analog input VIN-, the output of the comparator is 0. When the analog input at VIN+ is greater than the analog input VIN-, the output of the comparator is 1.
The inputs can be selected from the analog inputs multiplexed with pins C.1, C.2, C.5, C.6, as well as from the on-chip voltage reference module.
The comparison results of GPIO-24 adaptor comparators COMP0 and COMP1 can be retrieved with GPIO_GET_CMP_VAL command. Also, you can configure the comparator to send events (GPIO_EV_CMP) with the results of comparison. The events can be generated when the comparison results change or periodically with predefined interval (for more detailed information see Section 8.3, “Comparator module event”). In some configurations the results of comparison can be output on C.4, B.3 pins. You can invert comparators outputs with Bit 5: CMP0_INV and Bit 4: CMP1_INV in Byte 2: CMP_CFG of GPIO_SET_CMP_CFG command.
There are eight modes of operation for the comparator module. They are described in Section 8.1, “Modes of operation for comparator module”. Bits 3-0: MODE in Byte 2: CMP_CFG of GPIO_SET_CMP_CFG command are used to select a mode.
You can use the following commands for the comparator module:
Comparator module event (GPIO_EV_CMP) can be generated for either of the comparators. The event contains the comparison result (for more detailed information see Section 8.3, “Comparator module event”).