![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
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 operate the ACMP module better. This driver can be considered as a basic comparator with advanced features. The APIs for 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.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/acmp
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/acmp
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_channel_config_t |
Configuration for channel. More... | |
struct | acmp_filter_config_t |
Configuration for filter. More... | |
struct | acmp_dac_config_t |
Configuration for DAC. More... | |
struct | acmp_round_robin_config_t |
Configuration for round robin mode. More... | |
struct | acmp_discrete_mode_config_t |
Configuration for discrete mode. More... | |
Macros | |
#define | CMP_C0_CFx_MASK (CMP_C0_CFR_MASK | CMP_C0_CFF_MASK) |
The mask of status flags cleared by writing 1. More... | |
#define | CMP_C0_CFx_MASK (CMP_C0_CFR_MASK | CMP_C0_CFF_MASK) |
The mask of status flags cleared by writing 1. More... | |
Driver version | |
#define | FSL_ACMP_DRIVER_VERSION (MAKE_VERSION(2U, 0U, 5U)) |
ACMP driver version 2.0.5. More... | |
Initialization and deinitialization | |
void | ACMP_Init (CMP_Type *base, const acmp_config_t *config) |
Initializes the ACMP. More... | |
void | ACMP_Deinit (CMP_Type *base) |
Deinitializes the ACMP. More... | |
void | ACMP_GetDefaultConfig (acmp_config_t *config) |
Gets the default configuration for ACMP. More... | |
Basic Operations | |
void | ACMP_Enable (CMP_Type *base, bool enable) |
Enables or disables the ACMP. More... | |
void | ACMP_EnableLinkToDAC (CMP_Type *base, bool enable) |
Enables the link from CMP to DAC enable. More... | |
void | ACMP_SetChannelConfig (CMP_Type *base, const acmp_channel_config_t *config) |
Sets the channel configuration. More... | |
Advanced Operations | |
void | ACMP_EnableDMA (CMP_Type *base, bool enable) |
Enables or disables DMA. More... | |
void | ACMP_EnableWindowMode (CMP_Type *base, bool enable) |
Enables or disables window mode. More... | |
void | ACMP_SetFilterConfig (CMP_Type *base, const acmp_filter_config_t *config) |
Configures the filter. More... | |
void | ACMP_SetDACConfig (CMP_Type *base, const acmp_dac_config_t *config) |
Configures the internal DAC. More... | |
void | ACMP_SetRoundRobinConfig (CMP_Type *base, const acmp_round_robin_config_t *config) |
Configures the round robin mode. More... | |
void | ACMP_SetRoundRobinPreState (CMP_Type *base, uint32_t mask) |
Defines the pre-set state of channels in round robin mode. More... | |
static uint32_t | ACMP_GetRoundRobinStatusFlags (CMP_Type *base) |
Gets the channel input changed flags in round robin mode. More... | |
void | ACMP_ClearRoundRobinStatusFlags (CMP_Type *base, uint32_t mask) |
Clears the channel input changed flags in round robin mode. More... | |
static uint32_t | ACMP_GetRoundRobinResult (CMP_Type *base) |
Gets the round robin result. More... | |
Interrupts | |
void | ACMP_EnableInterrupts (CMP_Type *base, uint32_t mask) |
Enables interrupts. More... | |
void | ACMP_DisableInterrupts (CMP_Type *base, uint32_t mask) |
Disables interrupts. More... | |
Status | |
uint32_t | ACMP_GetStatusFlags (CMP_Type *base) |
Gets status flags. More... | |
void | ACMP_ClearStatusFlags (CMP_Type *base, uint32_t mask) |
Clears status flags. More... | |
Discrete mode | |
void | ACMP_SetDiscreteModeConfig (CMP_Type *base, const acmp_discrete_mode_config_t *config) |
Configure the discrete mode. More... | |
void | ACMP_GetDefaultDiscreteModeConfig (acmp_discrete_mode_config_t *config) |
Get the default configuration for discrete mode setting. More... | |
Driver version | |
#define | FSL_ACMP_DRIVER_VERSION (MAKE_VERSION(2U, 0U, 5U)) |
ACMP driver version 2.0.5. More... | |
struct acmp_config_t |
Data Fields | |
acmp_hysteresis_mode_t | hysteresisMode |
Hysteresis mode. More... | |
bool | enableHighSpeed |
Enable High Speed (HS) comparison mode. More... | |
bool | enableInvertOutput |
Enable inverted comparator output. More... | |
bool | useUnfilteredOutput |
Set compare output(COUT) to equal COUTA(true) or COUT(false). More... | |
bool | enablePinOut |
The comparator output is available on the associated pin. More... | |
acmp_hysteresis_mode_t acmp_config_t::hysteresisMode |
bool acmp_config_t::enableHighSpeed |
bool acmp_config_t::enableInvertOutput |
bool acmp_config_t::useUnfilteredOutput |
bool acmp_config_t::enablePinOut |
struct acmp_channel_config_t |
The comparator's port can be input from channel mux or DAC. If port input is from channel mux, detailed channel number for the mux should be configured.
Data Fields | |
uint32_t | plusMuxInput |
Plus mux input channel(0~7). More... | |
uint32_t | minusMuxInput |
Minus mux input channel(0~7). More... | |
uint32_t acmp_channel_config_t::plusMuxInput |
uint32_t acmp_channel_config_t::minusMuxInput |
struct acmp_filter_config_t |
Data Fields | |
bool | enableSample |
Using external SAMPLE as sampling clock input, or using divided bus clock. More... | |
uint32_t | filterCount |
Filter Sample Count. More... | |
uint32_t | filterPeriod |
Filter Sample Period. More... | |
bool acmp_filter_config_t::enableSample |
uint32_t acmp_filter_config_t::filterCount |
Available range is 1-7, 0 would cause the filter disabled.
uint32_t acmp_filter_config_t::filterPeriod |
The divider to bus clock. Available range is 0-255.
struct acmp_dac_config_t |
Data Fields | |
acmp_reference_voltage_source_t | referenceVoltageSource |
Supply voltage reference source. More... | |
uint32_t | DACValue |
Value for DAC Output Voltage. More... | |
bool | enableOutput |
Enable the DAC output. More... | |
acmp_reference_voltage_source_t acmp_dac_config_t::referenceVoltageSource |
uint32_t acmp_dac_config_t::DACValue |
Available range is 0-63.
bool acmp_dac_config_t::enableOutput |
struct acmp_round_robin_config_t |
Data Fields | |
acmp_fixed_port_t | fixedPort |
Fixed mux port. More... | |
uint32_t | fixedChannelNumber |
Indicates which channel is fixed in the fixed mux port. More... | |
uint32_t | checkerChannelMask |
Mask of checker channel index. More... | |
uint32_t | sampleClockCount |
Specifies how many round-robin clock cycles(0~3) later the sample takes place. More... | |
uint32_t | delayModulus |
Comparator and DAC initialization delay modulus. More... | |
acmp_fixed_port_t acmp_round_robin_config_t::fixedPort |
uint32_t acmp_round_robin_config_t::fixedChannelNumber |
uint32_t acmp_round_robin_config_t::checkerChannelMask |
Available range is channel0:0x01 to channel7:0x80 for round-robin checker.
uint32_t acmp_round_robin_config_t::sampleClockCount |
uint32_t acmp_round_robin_config_t::delayModulus |
struct acmp_discrete_mode_config_t |
Data Fields | |
bool | enablePositiveChannelDiscreteMode |
Positive Channel Continuous Mode Enable. More... | |
bool | enableNegativeChannelDiscreteMode |
Negative Channel Continuous Mode Enable. More... | |
bool | enableResistorDivider |
Resistor Divider Enable is used to enable the resistor divider for the inputs when they come from 3v domain and their values are above 1.8v. More... | |
acmp_discrete_clock_source_t | clockSource |
Select the clock source in order to generate the requiried timing for comparator to work in discrete mode. More... | |
acmp_discrete_sample_time_t | sampleTime |
Select the ACMP total sampling time period. More... | |
acmp_discrete_phase_time_t | phase1Time |
Select the ACMP phase 1 sampling time. More... | |
acmp_discrete_phase_time_t | phase2Time |
Select the ACMP phase 2 sampling time. More... | |
bool acmp_discrete_mode_config_t::enablePositiveChannelDiscreteMode |
By default, the continuous mode is used.
bool acmp_discrete_mode_config_t::enableNegativeChannelDiscreteMode |
By default, the continuous mode is used.
bool acmp_discrete_mode_config_t::enableResistorDivider |
acmp_discrete_clock_source_t acmp_discrete_mode_config_t::clockSource |
acmp_discrete_sample_time_t acmp_discrete_mode_config_t::sampleTime |
acmp_discrete_phase_time_t acmp_discrete_mode_config_t::phase1Time |
acmp_discrete_phase_time_t acmp_discrete_mode_config_t::phase2Time |
#define FSL_ACMP_DRIVER_VERSION (MAKE_VERSION(2U, 0U, 5U)) |
#define CMP_C0_CFx_MASK (CMP_C0_CFR_MASK | CMP_C0_CFF_MASK) |
#define FSL_ACMP_DRIVER_VERSION (MAKE_VERSION(2U, 0U, 5U)) |
#define CMP_C0_CFx_MASK (CMP_C0_CFR_MASK | CMP_C0_CFF_MASK) |
enum _acmp_status_flags |
See chip data sheet to get the actual hysteresis value with each level.
enum acmp_fixed_port_t |
enum acmp_dac_work_mode_t |
These values configures the analog comparator sampling timing (speicified by the discrete mode clock period T which is selected by acmp_discrete_clock_source_t) in discrete mode.
There are two phases for sampling input signals, phase 1 and phase 2.
enum _acmp_status_flags |
See chip data sheet to get the actual hysteresis value with each level.
enum acmp_fixed_port_t |
enum acmp_dac_work_mode_t |
These values configures the analog comparator sampling timing (speicified by the discrete mode clock period T which is selected by acmp_discrete_clock_source_t) in discrete mode.
There are two phases for sampling input signals, phase 1 and phase 2.
void ACMP_Init | ( | CMP_Type * | base, |
const acmp_config_t * | config | ||
) |
The default configuration can be got by calling ACMP_GetDefaultConfig().
base | ACMP peripheral base address. |
config | Pointer to ACMP configuration structure. |
void ACMP_Deinit | ( | CMP_Type * | base | ) |
base | ACMP peripheral base address. |
void ACMP_GetDefaultConfig | ( | acmp_config_t * | config | ) |
This function initializes the user configuration structure to default value. The default value are:
Example:
config | Pointer to ACMP configuration structure. |
void ACMP_Enable | ( | CMP_Type * | base, |
bool | enable | ||
) |
base | ACMP peripheral base address. |
enable | True to enable the ACMP. |
void ACMP_EnableLinkToDAC | ( | CMP_Type * | base, |
bool | enable | ||
) |
When this bit is set, the DAC enable/disable is controlled by the bit CMP_C0[EN] instead of CMP_C1[DACEN].
base | ACMP peripheral base address. |
enable | Enable the feature or not. |
void ACMP_SetChannelConfig | ( | CMP_Type * | base, |
const acmp_channel_config_t * | config | ||
) |
Note that the plus/minus mux's setting is only valid when the positive/negative port's input isn't from DAC but from channel mux.
Example:
base | ACMP peripheral base address. |
config | Pointer to channel configuration structure. |
void ACMP_EnableDMA | ( | CMP_Type * | base, |
bool | enable | ||
) |
base | ACMP peripheral base address. |
enable | True to enable DMA. |
void ACMP_EnableWindowMode | ( | CMP_Type * | base, |
bool | enable | ||
) |
base | ACMP peripheral base address. |
enable | True to enable window mode. |
void ACMP_SetFilterConfig | ( | CMP_Type * | base, |
const acmp_filter_config_t * | config | ||
) |
The filter can be enabled when the filter count is bigger than 1, the filter period is greater than 0 and the sample clock is from divided bus clock or the filter is bigger than 1 and the sample clock is from external clock. Detailed usage can be got from the reference manual.
Example:
base | ACMP peripheral base address. |
config | Pointer to filter configuration structure. |
void ACMP_SetDACConfig | ( | CMP_Type * | base, |
const acmp_dac_config_t * | config | ||
) |
Example:
base | ACMP peripheral base address. |
config | Pointer to DAC configuration structure. "NULL" is for disabling the feature. |
void ACMP_SetRoundRobinConfig | ( | CMP_Type * | base, |
const acmp_round_robin_config_t * | config | ||
) |
Example:
base | ACMP peripheral base address. |
config | Pointer to round robin mode configuration structure. "NULL" is for disabling the feature. |
void ACMP_SetRoundRobinPreState | ( | CMP_Type * | base, |
uint32_t | mask | ||
) |
Note: The pre-state has different circuit with get-round-robin-result in the SOC even though they are same bits. So get-round-robin-result can't return the same value as the value are set by pre-state.
base | ACMP peripheral base address. |
mask | Mask of round robin channel index. Available range is channel0:0x01 to channel7:0x80. |
|
inlinestatic |
base | ACMP peripheral base address. |
void ACMP_ClearRoundRobinStatusFlags | ( | CMP_Type * | base, |
uint32_t | mask | ||
) |
base | ACMP peripheral base address. |
mask | Mask of channel index. Available range is channel0:0x01 to channel7:0x80. |
|
inlinestatic |
Note that the set-pre-state has different circuit with get-round-robin-result in the SOC even though they are same bits. So ACMP_GetRoundRobinResult() can't return the same value as the value are set by ACMP_SetRoundRobinPreState.
base | ACMP peripheral base address. |
void ACMP_EnableInterrupts | ( | CMP_Type * | base, |
uint32_t | mask | ||
) |
base | ACMP peripheral base address. |
mask | Interrupts mask. See "_acmp_interrupt_enable". |
void ACMP_DisableInterrupts | ( | CMP_Type * | base, |
uint32_t | mask | ||
) |
base | ACMP peripheral base address. |
mask | Interrupts mask. See "_acmp_interrupt_enable". |
uint32_t ACMP_GetStatusFlags | ( | CMP_Type * | base | ) |
base | ACMP peripheral base address. |
void ACMP_ClearStatusFlags | ( | CMP_Type * | base, |
uint32_t | mask | ||
) |
base | ACMP peripheral base address. |
mask | Status flags mask. See "_acmp_status_flags". |
void ACMP_SetDiscreteModeConfig | ( | CMP_Type * | base, |
const acmp_discrete_mode_config_t * | config | ||
) |
Configure the discrete mode when supporting 3V domain with 1.8V core.
base | ACMP peripheral base address. |
config | Pointer to configuration structure. See "acmp_discrete_mode_config_t". |
void ACMP_GetDefaultDiscreteModeConfig | ( | acmp_discrete_mode_config_t * | config | ) |
config | Pointer to configuration structure to be restored with the setting values. |