1.13.5 Comparator (CMP)

The CMP peripheral consists of five comparators and four Op Amps. The Op Amp Comparator module 4 does not have the associated Op Amp. Inputs for these comparators can be selected from I/O pins or the Control Digital-to-Analog Converter 3 (CDAC3).

Using The Library

CMP Peripheral library provides API's that can be used to perform below functionalities on the CMP peripheral.

  • Initialize the CMP.

  • Turn on and turn off the individual comparators inside the CMP peripheral.

  • Register callback function for the five comparators inside the CMP peripheral.

  • Get the status of individual comparator output

Library Interface

peripheral library provides the following interfaces:

Functions

Name Description
CMP_Initialize Initializes CMP module of the device
CMP_1_CompareEnable Turn on CMP1
CMP_1_CompareDisable Turn off CMP1
CMP_2_CompareEnable Turn on CMP2
CMP_2_CompareDisable Turn off CMP2
CMP_3_CompareEnable Turn on CMP3
CMP_3_CompareDisable Turn off CMP3
CMP_4_CompareEnable Turn on CMP4
CMP_4_CompareDisable Turn off CMP4
CMP_5_CompareEnable Turn on CMP5
CMP_5_CompareDisable Turn off CMP5
CMP_StatusGet Returns the output state of a comparator
CMP_1_CallbackRegister Registers the function to be called from interrupt
CMP_2_CallbackRegister Registers the function to be called from interrupt
CMP_3_CallbackRegister Registers the function to be called from interrupt
CMP_4_CallbackRegister Registers the function to be called from interrupt
CMP_5_CallbackRegister Registers the function to be called from interrupt

Data types and constants

Name Type Description
CMP_STATUS_SOURCE Enum Denotes a specific comparator output status
CMP_CALLBACK Typedef Defines the function pointer data type and function signature for the CMP callback function