MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ACMP: Analog Comparator Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the Comparator (ACMP) module of MCUXpresso SDK devices.

Typical use case

Normal Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/acmp

Interrupt Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/acmp

Data Structures

struct  acmp_config_t
 Configuration for ACMP. More...
 
struct  acmp_dac_config_t
 Configuration for Internal DAC. More...
 

Enumerations

enum  acmp_hysterisis_mode_t {
  kACMP_HysterisisLevel1 = 0U,
  kACMP_HysterisisLevel2 = 1U
}
 Analog Comparator Hysterisis Selection. More...
 
enum  acmp_reference_voltage_source_t {
  kACMP_VrefSourceVin1 = 0U,
  kACMP_VrefSourceVin2 = 1U
}
 DAC Voltage Reference source. More...
 
enum  acmp_interrupt_mode_t {
  kACMP_OutputFallingInterruptMode = 0U,
  kACMP_OutputRisingInterruptMode = 1U,
  kACMP_OutputBothEdgeInterruptMode = 3U
}
 The sensitivity modes of the interrupt trigger. More...
 
enum  acmp_input_channel_selection_t {
  kACMP_ExternalReference0 = 0U,
  kACMP_ExternalReference1 = 1U,
  kACMP_ExternalReference2 = 2U,
  kACMP_InternalDACOutput = 3U
}
 The ACMP input channel selection. More...
 
enum  _acmp_status_flags {
  kACMP_InterruptFlag = ACMP_CS_ACF_MASK,
  kACMP_OutputFlag = ACMP_CS_ACO_MASK
}
 The ACMP status flags. More...
 

Driver version

#define FSL_ACMP_DRIVER_VERSION   (MAKE_VERSION(2U, 0U, 2U))
 ACMP driver version 2.0.2. More...
 

Initialization and deinitialization

void ACMP_Init (ACMP_Type *base, const acmp_config_t *config)
 Initialize the ACMP. More...
 
void ACMP_Deinit (ACMP_Type *base)
 De-Initialize the ACMP. More...
 
void ACMP_GetDefaultConfig (acmp_config_t *config)
 Gets the default configuration for ACMP. More...
 
static void ACMP_Enable (ACMP_Type *base, bool enable)
 Enable/Disable the ACMP module. More...
 
void ACMP_EnableInterrupt (ACMP_Type *base, acmp_interrupt_mode_t mode)
 Enable the ACMP interrupt and determines the sensitivity modes of the interrupt trigger. More...
 
static void ACMP_DisableInterrupt (ACMP_Type *base)
 Disable the ACMP interrupt. More...
 
void ACMP_SetChannelConfig (ACMP_Type *base, acmp_input_channel_selection_t PositiveInput, acmp_input_channel_selection_t negativeInout)
 Configure the ACMP positive and negative input channel. More...
 
void ACMP_SetDACConfig (ACMP_Type *base, const acmp_dac_config_t *config)
 
void ACMP_EnableInputPin (ACMP_Type *base, uint32_t mask, bool enable)
 Enable/Disable ACMP input pin. More...
 
static uint8_t ACMP_GetStatusFlags (ACMP_Type *base)
 Get ACMP status flags. More...
 
static void ACMP_ClearInterruptFlags (ACMP_Type *base)
 Clear interrupts status flag. More...
 

Data Structure Documentation

struct acmp_config_t

Data Fields

bool enablePinOut
 The comparator output is available on the associated pin. More...
 
acmp_hysterisis_mode_t hysteresisMode
 Hysteresis mode. More...
 

Field Documentation

bool acmp_config_t::enablePinOut
acmp_hysterisis_mode_t acmp_config_t::hysteresisMode
struct acmp_dac_config_t

Data Fields

uint8_t DACValue
 Value for DAC Output Voltage. More...
 
acmp_reference_voltage_source_t referenceVoltageSource
 Supply voltage reference source. More...
 

Field Documentation

uint8_t acmp_dac_config_t::DACValue

Available range is 0-63.

acmp_reference_voltage_source_t acmp_dac_config_t::referenceVoltageSource

Macro Definition Documentation

#define FSL_ACMP_DRIVER_VERSION   (MAKE_VERSION(2U, 0U, 2U))

Enumeration Type Documentation

Enumerator
kACMP_HysterisisLevel1 

ACMP hysterisis is 20mv.

>

kACMP_HysterisisLevel2 

ACMP hysterisis is 30mv.

>

Enumerator
kACMP_VrefSourceVin1 

The DAC selects Bandgap as the reference.

kACMP_VrefSourceVin2 

The DAC selects VDDA as the reference.

Enumerator
kACMP_OutputFallingInterruptMode 

ACMP interrupt on output falling edge.

>

kACMP_OutputRisingInterruptMode 

ACMP interrupt on output rising edge.

>

kACMP_OutputBothEdgeInterruptMode 

ACMP interrupt on output falling or rising edge.

>

Enumerator
kACMP_ExternalReference0 

External reference 0 is selected to as input channel.

>

kACMP_ExternalReference1 

External reference 1 is selected to as input channel.

>

kACMP_ExternalReference2 

External reference 2 is selected to as input channel.

>

kACMP_InternalDACOutput 

Internal DAC putput is selected to as input channel.

>

Enumerator
kACMP_InterruptFlag 

ACMP interrupt on output valid edge.

>

kACMP_OutputFlag 

The current value of the analog comparator output.

>

Function Documentation

void ACMP_Init ( ACMP_Type *  base,
const acmp_config_t config 
)

The default configuration can be got by calling ACMP_GetDefaultConfig().

Parameters
baseACMP peripheral base address.
configPointer to ACMP configuration structure.
void ACMP_Deinit ( ACMP_Type *  base)
Parameters
baseACMP peripheral basic address.
void ACMP_GetDefaultConfig ( acmp_config_t config)

This function initializes the user configuration structure to default value. The default value are: Example:

* config->enablePinOut = false;
* config->hysteresisMode = kACMP_HysterisisLevel1;
*
Parameters
configPointer to ACMP configuration structure.
static void ACMP_Enable ( ACMP_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseACMP peripheral base address.
enableSwitcher to enable/disable ACMP module.
void ACMP_EnableInterrupt ( ACMP_Type *  base,
acmp_interrupt_mode_t  mode 
)
Parameters
baseACMP peripheral base address.
modeSelect one interrupt mode to generate interrupt.
static void ACMP_DisableInterrupt ( ACMP_Type *  base)
inlinestatic
Parameters
baseACMP peripheral base address.
void ACMP_SetChannelConfig ( ACMP_Type *  base,
acmp_input_channel_selection_t  PositiveInput,
acmp_input_channel_selection_t  negativeInout 
)
Parameters
baseACMP peripheral base address.
PositiveInputACMP Positive Input Select. Refer to "acmp_input_channel_selection_t".
negativeInoutACMP Negative Input Select. Refer to "acmp_input_channel_selection_t".
void ACMP_EnableInputPin ( ACMP_Type *  base,
uint32_t  mask,
bool  enable 
)
   The API controls if the corresponding ACMP external pin can be driven by an analog input
Parameters
baseACMP peripheral base address.
maskThe mask of the pin associated with channel ADx. Valid range is AD0:0x1U ~ AD3:0x4U. For example: If enable AD0, AD1 and AD2 pins, mask should be set to 0x7U(0x1 | 0x2 | 0x4).
enableSwitcher to enable/disable ACMP module.
static uint8_t ACMP_GetStatusFlags ( ACMP_Type *  base)
inlinestatic
Parameters
baseACMP peripheral base address.
Returns
Flags' mask if indicated flags are asserted. See "_acmp_status_flags".
static void ACMP_ClearInterruptFlags ( ACMP_Type *  base)
inlinestatic
Parameters
baseACMP peripheral base address.