|
#define | CMP_C0_CFx_MASK (CMP_C0_CFR_MASK | CMP_C0_CFF_MASK) |
| The mask of status flags cleared by writing 1. More...
|
|
|
enum | _acmp_interrupt_enable {
kACMP_OutputRisingInterruptEnable = (1U << 0U),
kACMP_OutputFallingInterruptEnable = (1U << 1U),
kACMP_RoundRobinInterruptEnable = (1U << 2U)
} |
| Interrupt enable/disable mask. More...
|
|
enum | _acmp_status_flags {
kACMP_OutputRisingEventFlag = CMP_C0_CFR_MASK,
kACMP_OutputFallingEventFlag = CMP_C0_CFF_MASK,
kACMP_OutputAssertEventFlag = CMP_C0_COUT_MASK
} |
| Status flag mask. More...
|
|
enum | acmp_hysteresis_mode_t {
kACMP_HysteresisLevel0 = 0U,
kACMP_HysteresisLevel1 = 1U,
kACMP_HysteresisLevel2 = 2U,
kACMP_HysteresisLevel3 = 3U
} |
| Comparator hard block hysteresis control. More...
|
|
enum | acmp_reference_voltage_source_t {
kACMP_VrefSourceVin1 = 0U,
kACMP_VrefSourceVin2 = 1U
} |
| CMP Voltage Reference source. More...
|
|
enum | acmp_fixed_port_t {
kACMP_FixedPlusPort = 0U,
kACMP_FixedMinusPort = 1U
} |
| Fixed mux port. More...
|
|
enum | acmp_dac_work_mode_t {
kACMP_DACWorkLowSpeedMode = 0U,
kACMP_DACWorkHighSpeedMode = 1U
} |
| Internal DAC's work mode. More...
|
|
enum | acmp_discrete_clock_source_t {
kACMP_DiscreteClockSlow = 0U,
kACMP_DiscreteClockFast = 1U
} |
| Discrete mode clock selection. More...
|
|
enum | acmp_discrete_sample_time_t {
kACMP_DiscreteSampleTimeAs1T = 0U,
kACMP_DiscreteSampleTimeAs2T = 1U,
kACMP_DiscreteSampleTimeAs4T = 2U,
kACMP_DiscreteSampleTimeAs8T = 3U,
kACMP_DiscreteSampleTimeAs16T = 4U,
kACMP_DiscreteSampleTimeAs32T = 5U,
kACMP_DiscreteSampleTimeAs64T = 6U,
kACMP_DiscreteSampleTimeAs256T = 7U
} |
| ACMP discrete sample selection. More...
|
|
enum | acmp_discrete_phase_time_t {
kACMP_DiscretePhaseTimeAlt0 = 0U,
kACMP_DiscretePhaseTimeAlt1 = 1U,
kACMP_DiscretePhaseTimeAlt2 = 2U,
kACMP_DiscretePhaseTimeAlt3 = 3U,
kACMP_DiscretePhaseTimeAlt4 = 4U,
kACMP_DiscretePhaseTimeAlt5 = 5U,
kACMP_DiscretePhaseTimeAlt6 = 6U,
kACMP_DiscretePhaseTimeAlt7 = 7U
} |
| ACMP discrete phase time selection. More...
|
|
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.
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
Round robin Configuration
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/acmp
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.
uint32_t acmp_channel_config_t::plusMuxInput |
uint32_t acmp_channel_config_t::minusMuxInput |
struct acmp_filter_config_t |
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.
uint32_t acmp_dac_config_t::DACValue |
struct acmp_round_robin_config_t |
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 |
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 |
#define CMP_C0_CFx_MASK (CMP_C0_CFR_MASK | CMP_C0_CFF_MASK) |
Enumerator |
---|
kACMP_OutputRisingInterruptEnable |
Enable the interrupt when comparator outputs rising.
|
kACMP_OutputFallingInterruptEnable |
Enable the interrupt when comparator outputs falling.
|
kACMP_RoundRobinInterruptEnable |
Enable the Round-Robin interrupt.
|
Enumerator |
---|
kACMP_OutputRisingEventFlag |
Rising-edge on compare output has occurred.
|
kACMP_OutputFallingEventFlag |
Falling-edge on compare output has occurred.
|
kACMP_OutputAssertEventFlag |
Return the current value of the analog comparator output.
|
See chip data sheet to get the actual hysteresis value with each level.
Enumerator |
---|
kACMP_HysteresisLevel0 |
Offset is level 0 and Hysteresis is level 0.
|
kACMP_HysteresisLevel1 |
Offset is level 0 and Hysteresis is level 1.
|
kACMP_HysteresisLevel2 |
Offset is level 0 and Hysteresis is level 2.
|
kACMP_HysteresisLevel3 |
Offset is level 0 and Hysteresis is level 3.
|
Enumerator |
---|
kACMP_VrefSourceVin1 |
Vin1 is selected as resistor ladder network supply reference Vin.
|
kACMP_VrefSourceVin2 |
Vin2 is selected as resistor ladder network supply reference Vin.
|
Enumerator |
---|
kACMP_FixedPlusPort |
Only the inputs to the Minus port are swept in each round.
|
kACMP_FixedMinusPort |
Only the inputs to the Plus port are swept in each round.
|
Enumerator |
---|
kACMP_DACWorkLowSpeedMode |
DAC is selected to work in low speed and low power mode.
|
kACMP_DACWorkHighSpeedMode |
DAC is selected to work in high speed high power mode.
|
Enumerator |
---|
kACMP_DiscreteClockSlow |
Slow clock (32kHz) is used as the discrete mode clock.
|
kACMP_DiscreteClockFast |
Fast clock (16-20MHz) is used as the discrete mode clock.
|
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.
Enumerator |
---|
kACMP_DiscreteSampleTimeAs1T |
The sampling time equals to 1xT.
|
kACMP_DiscreteSampleTimeAs2T |
The sampling time equals to 2xT.
|
kACMP_DiscreteSampleTimeAs4T |
The sampling time equals to 4xT.
|
kACMP_DiscreteSampleTimeAs8T |
The sampling time equals to 8xT.
|
kACMP_DiscreteSampleTimeAs16T |
The sampling time equals to 16xT.
|
kACMP_DiscreteSampleTimeAs32T |
The sampling time equals to 32xT.
|
kACMP_DiscreteSampleTimeAs64T |
The sampling time equals to 64xT.
|
kACMP_DiscreteSampleTimeAs256T |
The sampling time equals to 256xT.
|
There are two phases for sampling input signals, phase 1 and phase 2.
Enumerator |
---|
kACMP_DiscretePhaseTimeAlt0 |
The phase x active in one sampling selection 0.
|
kACMP_DiscretePhaseTimeAlt1 |
The phase x active in one sampling selection 1.
|
kACMP_DiscretePhaseTimeAlt2 |
The phase x active in one sampling selection 2.
|
kACMP_DiscretePhaseTimeAlt3 |
The phase x active in one sampling selection 3.
|
kACMP_DiscretePhaseTimeAlt4 |
The phase x active in one sampling selection 4.
|
kACMP_DiscretePhaseTimeAlt5 |
The phase x active in one sampling selection 5.
|
kACMP_DiscretePhaseTimeAlt6 |
The phase x active in one sampling selection 6.
|
kACMP_DiscretePhaseTimeAlt7 |
The phase x active in one sampling selection 7.
|
The default configuration can be got by calling ACMP_GetDefaultConfig().
- Parameters
-
base | ACMP peripheral base address. |
config | Pointer to ACMP configuration structure. |
void ACMP_Deinit |
( |
CMP_Type * |
base | ) |
|
- Parameters
-
base | ACMP peripheral base address. |
This function initializes the user configuration structure to default value. The default value are:
Example:
config->enableHighSpeed = false;
config->enableInvertOutput = false;
config->useUnfilteredOutput = false;
config->enablePinOut = false;
config->enableHysteresisBothDirections = false;
config->hysteresisMode = kACMP_hysteresisMode0;
- Parameters
-
config | Pointer to ACMP configuration structure. |
void ACMP_Enable |
( |
CMP_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
- Parameters
-
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].
- Parameters
-
base | ACMP peripheral base address. |
enable | Enable the feature or not. |
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:
configStruct.positivePortInput = kACMP_PortInputFromDAC;
configStruct.negativePortInput = kACMP_PortInputFromMux;
- Parameters
-
base | ACMP peripheral base address. |
config | Pointer to channel configuration structure. |
void ACMP_EnableDMA |
( |
CMP_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
- Parameters
-
base | ACMP peripheral base address. |
enable | True to enable DMA. |
void ACMP_EnableWindowMode |
( |
CMP_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
- Parameters
-
base | ACMP peripheral base address. |
enable | True to enable window mode. |
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:
- Parameters
-
base | ACMP peripheral base address. |
config | Pointer to filter configuration structure. |
Example:
configStruct.enableOutput = false;
- Parameters
-
base | ACMP peripheral base address. |
config | Pointer to DAC configuration structure. "NULL" is for disabling the feature. |
Example:
- Parameters
-
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.
- Parameters
-
base | ACMP peripheral base address. |
mask | Mask of round robin channel index. Available range is channel0:0x01 to channel7:0x80. |
static uint32_t ACMP_GetRoundRobinStatusFlags |
( |
CMP_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | ACMP peripheral base address. |
- Returns
- Mask of channel input changed asserted flags. Available range is channel0:0x01 to channel7:0x80.
void ACMP_ClearRoundRobinStatusFlags |
( |
CMP_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | ACMP peripheral base address. |
mask | Mask of channel index. Available range is channel0:0x01 to channel7:0x80. |
static uint32_t ACMP_GetRoundRobinResult |
( |
CMP_Type * |
base | ) |
|
|
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.
- Parameters
-
base | ACMP peripheral base address. |
- Returns
- Mask of round robin channel result. Available range is channel0:0x01 to channel7:0x80.
void ACMP_EnableInterrupts |
( |
CMP_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | ACMP peripheral base address. |
mask | Interrupts mask. See "_acmp_interrupt_enable". |
void ACMP_DisableInterrupts |
( |
CMP_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | ACMP peripheral base address. |
mask | Interrupts mask. See "_acmp_interrupt_enable". |
uint32_t ACMP_GetStatusFlags |
( |
CMP_Type * |
base | ) |
|
- Parameters
-
base | ACMP peripheral base address. |
- Returns
- Status flags asserted mask. See "_acmp_status_flags".
void ACMP_ClearStatusFlags |
( |
CMP_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | ACMP peripheral base address. |
mask | Status flags mask. See "_acmp_status_flags". |
Configure the discrete mode when supporting 3V domain with 1.8V core.
- Parameters
-
base | ACMP peripheral base address. |
config | Pointer to configuration structure. See "acmp_discrete_mode_config_t". |
- Parameters
-
config | Pointer to configuration structure to be restored with the setting values. |