2.1 Analog Comparators (AC)

The Analog Comparator peripheral (AC) supports four individual comparators. Each comparator (COMP) compares the voltage levels on two inputs ('+' and '-' input pins of the comparator), and provides a digital output based on this comparison. Each comparator may be configured to generate interrupt requests and/or peripheral events upon several different combinations of input change.

The AC peripheral implements one pair of comparators. Each pair can be set in window mode to compare a signal to a voltage range instead of a single voltage level.

Using The Library

AC Peripheral library provides non-Blocking API's and they can be used to perform below functionalities on the AC peripheral.

  • Initialize the AC.
  • Start comparison on a given comparator.
  • Swap inputs of a comparator.
  • Get status of a comparison operation.
  • Register a callback.

Library Interface

Analog Comparators peripheral library provides the following interfaces:

Functions

NameDescription
AC_InitializeInitializes AC module of the device
AC_StartTriggers a comparator to start comparison
AC_SwapInputsSwap inputs of a comparator
AC_ChannelSelectSelects the positive and negative inputs of a channel
AC_SetVddScalarSets VDDSCALER value of a comparator
AC_StatusGetReturns comparison status of the AC
AC_CallbackRegisterAllows application to register callback with PLIB

Data types and constants

NameTypeDescription
AC_CHANNELEnumIdentifies the AC output channel number
AC_POSINPUTEnumIdentifies the positive inputs of a comparator channel
AC_NEGINPUTEnumIdentifies negative inputs of a comparator channel
AC_CALLBACKTypedefAnalog comparator callback function pointer
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.