2.16 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

Comparator peripheral library provides the following interfaces:

Functions

NameDescription
CMP_InitializeInitializes CMP module of the device
CMP_1_CompareEnableTurn on CMP1
CMP_1_CompareDisableTurn off CMP1
CMP_2_CompareEnableTurn on CMP2
CMP_2_CompareDisableTurn off CMP2
CMP_3_CompareEnableTurn on CMP3
CMP_3_CompareDisableTurn off CMP3
CMP_4_CompareEnableTurn on CMP4
CMP_4_CompareDisableTurn off CMP4
CMP_5_CompareEnableTurn on CMP5
CMP_5_CompareDisableTurn off CMP5
CMP_StatusGetReturns the output state of a comparator
CMP_1_CallbackRegisterRegisters the function to be called from interrupt
CMP_2_CallbackRegisterRegisters the function to be called from interrupt
CMP_3_CallbackRegisterRegisters the function to be called from interrupt
CMP_4_CallbackRegisterRegisters the function to be called from interrupt
CMP_5_CallbackRegisterRegisters the function to be called from interrupt

Data types and constants

NameTypeDescription
CMP_STATUS_SOURCEEnumDenotes a specific comparator output status
CMP_CALLBACKTypedefDefines the function pointer data type and function signature for the CMP callback function
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.