ACMP - Analog Comparator

Description

Analog comparator (ACMP) Peripheral API.

The Analog Comparator is used to compare voltage of two analog inputs with a digital output indicating which input voltage is higher. Inputs can either be one of the selectable internal references or from external pins. Response time and current consumption can be configured by altering the current supply to the comparator.

ACMP is available down to EM3 and is able to wake up the system when input signals pass a certain threshold. Use ACMP_IntEnable() to enable an edge interrupt to use this functionality.

This example shows how to use the em_acmp.h API for comparing an input pin to an internal 2.5 V reference voltage.

/* The ACMP is a high-frequency peripheral so we need to enable
* both the HFPER clock and the ACMP0 clock. */
/* Initialize with default settings. */
init. enable = false ;
ACMP_Init (ACMP0, &init);
/* Setup the two channels to compare. The first argument is the negative
* channel and the second argument is the positive channel.
*
* Here we compare channel 0 with the 2.5 V internal reference. When
* channel 0 is lower than 2.5 V then the ACMP output is 0 and when
* channel 0 voltage is higher than 2.5 V then the ACMP output is 1. */
/* To be able to probe the output we can send the ACMP output to a pin.
* The second argument to this function is the pin location which is
* device dependent. */
ACMP_GPIOSetup (ACMP0, 0, true , false );
/* Finally we enable the ACMP. */
ACMP_Enable (ACMP0);
Note
ACMP can also be used to compare two separate input pins.

ACMP also contains specialized hardware for capacitive sensing. This module contains the ACMP_CapsenseInit() function to initialize ACMP for capacitive sensing and the ACMP_CapsenseChannelSet() function to select the current capsense channel.

For applications that require capacitive sensing it is recommended to use a library, such as cslib, which is provided by Silicon Labs.

Data Structures

struct ACMP_CapsenseInit_TypeDef
Capsense initialization structure.
struct ACMP_Init_TypeDef
ACMP initialization structure.

Functions

void ACMP_CapsenseInit (ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init)
Set up ACMP for use in capacitive sense applications.
void ACMP_CapsenseChannelSet (ACMP_TypeDef *acmp, ACMP_Channel_TypeDef channel)
Set the ACMP channel used for capacitive sensing.
void ACMP_ChannelSet (ACMP_TypeDef *acmp, ACMP_Channel_TypeDef negSel, ACMP_Channel_TypeDef posSel)
Set which channels should be used in ACMP comparisons.
void ACMP_Disable (ACMP_TypeDef *acmp)
Disable ACMP.
void ACMP_Enable (ACMP_TypeDef *acmp)
Enable ACMP.
void ACMP_GPIOSetup (ACMP_TypeDef *acmp, uint32_t location, bool enable, bool invert)
Set up GPIO output from ACMP.
void ACMP_Init (ACMP_TypeDef *acmp, const ACMP_Init_TypeDef *init)
Initialize ACMP.
void ACMP_Reset (ACMP_TypeDef *acmp)
Reset ACMP to the same state that it was in after a hardware reset.
void ACMP_IntClear (ACMP_TypeDef *acmp, uint32_t flags)
Clear one or more pending ACMP interrupts.
void ACMP_IntDisable (ACMP_TypeDef *acmp, uint32_t flags)
Disable one or more ACMP interrupts.
void ACMP_IntEnable (ACMP_TypeDef *acmp, uint32_t flags)
Enable one or more ACMP interrupts.
uint32_t