3.20.3 Comparator (CMP)

The CMP peripheral consists of two comparators (CMP1 and CMP2). Inputs for these comparators can be selected from various sources such as I/O pins, CVR and internal 1.2 volts reference (IVREF).

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 two comparators inside the CMP peripheral.

  • Get the status of individual comparator output

Library Interface

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_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

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