1.16.3 1.17.3 1.18.4 1.19.3 1.20.3 1.21.4 1.22.5 1.23.5 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

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

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