You are here

Comparator module event

Comparator module event (GPIO_EV_CMP) can be generated for either of the comparators.

The conditions of events generation is configured with Bits 3..0: COND0 and Bits 3..0: COND1 in Bytes 5 and 7 of GPIO_SET_CMP_CFG command.

The following values are available for these bits:

GPIO_CMP_EV_NONE (0x00)

The comparator does not send events. The comparison results still can be retrieved with GPIO_GET_CMP_VAL command.

GPIO_CMP_EV_CHANGE (0x01)

An event is sent when the comparison result changes.

GPIO_CMP_EV_ALWAYS (0x02)

Events are sent periodically with the predefined repeat interval. The repeat interval is a 12-bit value. This interval for CMP0 comparator can be specified in Byte 4: REPEAT0_LSB (8 least significant bits) and Bits 7..4 REPEAT0_MSB in Byte 5 (4 most significant bits) of GPIO_SET_CMP_CFG command. The repeat interval value for CMP1 comparator can be specified, correspondingly, in Byte 6: REPEAT1_LSB and Bits 7..4 REPEAT1_MSB in Byte 7. The repeat interval is set in units of 1 ms. It allows to specify repeat values from 1 ms to 4 s.

The GPIO_EV_CMP event returns the following information:

The event can be generated for either of the comparators or both of them. So, there are 3 possible situations:

  • if the value of Byte 4: EVENT_COND0 is not GPIO_CMP_EV_NONE (0x00), the event has been generated by the CMP0 comparator and Byte 2: CMP0_OUT contains valid data;

  • if the value of Byte 5: EVENT_COND1 is not GPIO_CMP_EV_NONE (0x00), the event has been generated by the CMP1 comparator and Byte 3: CMP1_OUT contains valid data;

  • if the value of Byte 4: EVENT_COND0 is not GPIO_CMP_EV_NONE (0x00) and the value of Byte 5: EVENT_COND1 is not GPIO_CMP_EV_NONE (0x00), the event has been generated by both comparators and the event contains valid data for both comparators.

The comparison results can be inverted for each comparator with Bit 5: CMP0_INV and Bit 4: CMP1_INV in Byte 2: CMP_CFG of GPIO_SET_CMP_CFG command.