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.

The ACMP driver is created to help the user better operate the ACMP module. This driver can be considered as a basic comparator with advanced features. The APIs for a basic comparator can make the CMP work as a general comparator, which compares the two input channel's voltage and creates the output of the comparator result immediately. The APIs for advanced feature can be used as the plug-in function based on the basic comparator, and can provide more ways to process the comparator's output.

Typical use case

Example use of ACMP API.

int main(void)
{
acmp_config_t config;
BOARD_InitHardware();
PRINTF("\r\nACMP example.\r\n");
/*PA24--ACMP0N*/
/*PA25--ACMP0P*/
config.ch = DEMO_ACMP_USER_CHANNEL;
config.refSrc = kACMP_ReferenceSourceVcc;
ACMP_Init(DEMO_ACMP_BASE, &config);
ACMP_EnableInterrupts(DEMO_ACMP_BASE, DEMO_ACMP_USER_CHANNEL);
ACMP_Enable(DEMO_ACMP_BASE, DEMO_ACMP_USER_CHANNEL);
NVIC_EnableIRQ(ACMP0_IRQn);
while (1)
{
while (!g_AcmpIntFlags)
{
}
PRINTF("\r\nACMP0 interrupt. Input voltage is higher than 0.75V\r\n");
g_AcmpIntFlags = 0;
}
}

Files

file  fsl_acmp.h
 

Data Structures

struct  acmp_config_t
 Describes ACMP configuration structure. More...
 

Enumerations

enum  acmp_channel_t {
  kACMP_Channel0 = 0U,
  kACMP_Channel1 = 1U
}
 Analog comparator channel. More...
 
enum  acmp_reference_voltage_source_t
 Analog comparator reference voltage source.
 
enum  acmp_hysteresis_t {
  kACMP_HysteresisDisable = 0U,
  kACMP_HysteresisEnable = 1U
}
 Analog comparator hysteresis status. More...
 
enum  acmp_triger_edge_t
 Analog comparator interrupt triger edge.
 
enum  acmp_reference_voltage_divider_t {
  kACMP_ReferenceVoltageDivider1 = 1U,
  kACMP_ReferenceVoltageDivider2,
  kACMP_ReferenceVoltageDivider3,
  kACMP_ReferenceVoltageDivider4,
  kACMP_ReferenceVoltageDivider5,
  kACMP_ReferenceVoltageDivider6,
  kACMP_ReferenceVoltageDivider7,
  kACMP_ReferenceVoltageDivider8,
  kACMP_ReferenceVoltageDivider9,
  kACMP_ReferenceVoltageDivider10,
  kACMP_ReferenceVoltageDivider11,
  kACMP_ReferenceVoltageDivider12,
  kACMP_ReferenceVoltageDivider13,
  kACMP_ReferenceVoltageDivider14,
  kACMP_ReferenceVoltageDivider15
}
 Analog comparator reference voltage divider. More...
 

Functions

void ACMP_Init (SYSCON_Type *base, const acmp_config_t *config)
 Initializes the ACMP with configuration. More...
 
void ACMP_Enable (SYSCON_Type *base, acmp_channel_t ch)
 Enable the ACMP module. More...
 
void ACMP_Disable (SYSCON_Type *base, acmp_channel_t ch)
 Disable the ACMP module. More...
 
void ACMP_EnableInterrupts (SYSCON_Type *base, acmp_channel_t ch)
 Enables the ACMP interrupt. More...
 
void ACMP_DisableInterrupts (SYSCON_Type *base, acmp_channel_t ch)
 Disables the ACMP interrupt. More...
 
uint8_t ACMP_GetValue (SYSCON_Type *base, acmp_channel_t ch)
 Get the ACMP value. More...
 
static void ACMP_Deinit (SYSCON_Type *base)
 Disable the ACMP module. More...
 
void ACMP_GetDefaultConfig (acmp_config_t *config)
 Gets the default configuration structure. More...
 

Driver version

#define FSL_ACMP_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 QN ACMP driver version.
 

Data Structure Documentation

struct acmp_config_t

Data Fields

acmp_channel_t ch
 Analog comparator channel.
 
acmp_reference_voltage_source_t refSrc
 Analog comparator reference voltage source.
 
acmp_reference_voltage_divider_t refDiv
 Analog comparator reference voltage divider.
 
acmp_hysteresis_t hystEn
 Analog comparator hysteresis.
 
acmp_triger_edge_t trigerEdge
 Analog comparator channel.
 

Enumeration Type Documentation

Enumerator
kACMP_Channel0 

Analog comparator channel 0.

kACMP_Channel1 

Analog comparator channel 1.

Enumerator
kACMP_HysteresisDisable 

Analog comparator disable Hysteresis.

kACMP_HysteresisEnable 

Analog comparator enable Hysteresis.

Enumerator
kACMP_ReferenceVoltageDivider1 

Set reference valtage to 1/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider2 

Set reference valtage to 2/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider3 

Set reference valtage to 3/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider4 

Set reference valtage to 4/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider5 

Set reference valtage to 5/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider6 

Set reference valtage to 6/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider7 

Set reference valtage to 7/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider8 

Set reference valtage to 8/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider9 

Set reference valtage to 9/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider10 

Set reference valtage to 10/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider11 

Set reference valtage to 11/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider12 

Set reference valtage to 12/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider13 

Set reference valtage to 13/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider14 

Set reference valtage to 14/16 Band-Gap Voltage or Vcc.

kACMP_ReferenceVoltageDivider15 

Set reference valtage to 15/16 Band-Gap Voltage or Vcc.

Function Documentation

void ACMP_Init ( SYSCON_Type *  base,
const acmp_config_t config 
)

This function configures the ACMP module with the user-defined settings.

Parameters
baseACMP peripheral base address.
configpointer to configuration structure
void ACMP_Enable ( SYSCON_Type *  base,
acmp_channel_t  ch 
)

This function enable the ACMP module.

Parameters
baseACMP peripheral base address.
chSpecified the channel to be enabled
void ACMP_Disable ( SYSCON_Type *  base,
acmp_channel_t  ch 
)

This function disable the ACMP module.

Parameters
baseACMP peripheral base address.
chSpecified the channel to be disabled
void ACMP_EnableInterrupts ( SYSCON_Type *  base,
acmp_channel_t  ch 
)

This function enables the ACMP interrupt.

Parameters
baseACMP peripheral base address.
chSpecified the channel.
void ACMP_DisableInterrupts ( SYSCON_Type *  base,
acmp_channel_t  ch 
)

This function disables the ACMP interrupt.

Parameters
baseACMP peripheral base address.
chSpecified the channel
uint8_t ACMP_GetValue ( SYSCON_Type *  base,
acmp_channel_t  ch 
)

This function get ACMP output value.

Parameters
baseACMP peripheral base address.
chSpecified the channel
Returns
acmp value
static void ACMP_Deinit ( SYSCON_Type *  base)
inlinestatic

This function disable the ACMP module.

Parameters
baseACMP peripheral base address.
void ACMP_GetDefaultConfig ( acmp_config_t config)

This function initializes the ACMP configuration structure to a default value. The default values are: config->ch = kACMP_Channel0; config->refSrc = kACMP_ReferenceSourceExternalReferenceVoltage; config->hystEn = kACMP_HysteresisDisable; config->trigerEdge = kACMP_TrigerRising; config->refDiv = kACMP_ReferenceVoltageDivider1;

Parameters
configPointer to configuration structure.