The MCUXpresso SDK provides a peripheral driver for the 12-bit Analog to Digital Converter (ADC) module of MCUXpresso SDK devices.
Typical use case
Interrupt Configuration
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/fsl_adc
Polling Configuration
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/fsl_adc
|
enum | adc_reference_voltage_source_t {
kADC_ReferenceVoltageSourceAlt0 = 0U,
kADC_ReferenceVoltageSourceAlt1 = 1U
} |
| Reference voltage source. More...
|
|
enum | adc_clock_divider_t {
kADC_ClockDivider1 = 0U,
kADC_ClockDivider2 = 1U,
kADC_ClockDivider4 = 2U,
kADC_ClockDivider8 = 3U
} |
| Clock divider for the converter. More...
|
|
enum | adc_resolution_mode_t {
kADC_Resolution8BitMode = 0U,
kADC_Resolution10BitMode = 1U,
kADC_Resolution12BitMode = 2U
} |
| ADC converter resolution mode. More...
|
|
enum | adc_clock_source_t {
kADC_ClockSourceAlt0 = 0U,
kADC_ClockSourceAlt1 = 1U,
kADC_ClockSourceAlt2 = 2U,
kADC_ClockSourceAlt3 = 3U
} |
| ADC input Clock source. More...
|
|
enum | adc_compare_mode_t {
kADC_CompareDisableMode = 0U,
kADC_CompareLessMode = 2U,
kADC_CompareGreaterOrEqualMode = 3U
} |
| Compare function mode. More...
|
|
enum | _adc_status_flags {
kADC_ActiveFlag = ADC_SC2_ADACT_MASK,
kADC_FifoEmptyFlag = ADC_SC2_FEMPTY_MASK,
kADC_FifoFullFlag = ADC_SC2_FFULL_MASK
} |
| ADC status flags mask. More...
|
|
enum | adc_hardware_trigger_mask_mode_t {
kADC_HWTriggerMaskDisableMode,
kADC_HWTriggerMaskAutoMode = 1U,
kADC_HWTriggerMaskEnableMode
} |
| Hardware tigger mask mode. More...
|
|
bool adc_config_t::enableLowPower |
The power is reduced at the expense of maximum clock speed. >
bool adc_config_t::enableLongSampleTime |
struct adc_hardware_compare_config_t |
uint32_t adc_hardware_compare_config_t::compareValue |
The value are compared to the conversion result. >
Refer to "adc_compare_mode_t". >
bool adc_fifo_config_t::enableHWTriggerMultConv |
One hardware trigger pulse triggers multiple conversions in fifo mode. >
bool adc_fifo_config_t::enableFifoScanMode |
Enable the FIFO scan mode. If enable, ADC will repeat using the first FIFO channel as the conversion channel until the result FIFO is fulfilled. >
bool adc_fifo_config_t::enableCompareAndMode |
If enable, ADC will AND all of compare triggers and set COCO after all of compare triggers occur. If disable, ADC will OR all of compare triggers and set COCO after at least one of compare trigger occurs. >
uint32_t adc_fifo_config_t::FifoDepth |
Depth of fifo is FifoDepth + 1. When FifoDepth = 0U, the FIFO is DISABLED. When FifoDepth is set to nonzero, the FIFO function is ENABLED and the depth is indicated by the FifoDepth field. >
struct adc_channel_config_t |
uint32_t adc_channel_config_t::channelNumber |
The available range is 0-31. See channel connection information for each chip in Reference Manual document.
bool adc_channel_config_t::enableContinuousConversion |
bool adc_channel_config_t::enableInterruptOnConversionCompleted |
Enumerator |
---|
kADC_ReferenceVoltageSourceAlt0 |
Default voltage reference pin pair (VREFH/VREFL).
>
|
kADC_ReferenceVoltageSourceAlt1 |
Analog supply pin pair (VDDA/VSSA).
>
|
Enumerator |
---|
kADC_ClockDivider1 |
Divide ration = 1, and clock rate = Input clock.
>
|
kADC_ClockDivider2 |
Divide ration = 2, and clock rate = Input clock / 2.
>
|
kADC_ClockDivider4 |
Divide ration = 3, and clock rate = Input clock / 4.
>
|
kADC_ClockDivider8 |
Divide ration = 4, and clock rate = Input clock / 8.
>
|
Enumerator |
---|
kADC_Resolution8BitMode |
8-bit conversion (N = 8).
>
|
kADC_Resolution10BitMode |
10-bit conversion (N = 10) >
|
kADC_Resolution12BitMode |
12-bit conversion (N = 12) >
|
Enumerator |
---|
kADC_ClockSourceAlt0 |
Bus clock.
>
|
kADC_ClockSourceAlt1 |
Bus clock divided by 2.
>
|
kADC_ClockSourceAlt2 |
Alternate clock (ALTCLK).
>
|
kADC_ClockSourceAlt3 |
Asynchronous clock (ADACK).
>
|
Enumerator |
---|
kADC_CompareDisableMode |
Compare function disabled.
>
|
kADC_CompareLessMode |
Compare triggers when input is less than compare level.
>
|
kADC_CompareGreaterOrEqualMode |
Compare triggers when input is greater than or equal to compare level.
>
|
Enumerator |
---|
kADC_ActiveFlag |
Indicates that a conversion is in progress.
>
|
kADC_FifoEmptyFlag |
Indicates that ADC result FIFO have no valid new data.
>
|
kADC_FifoFullFlag |
Indicates that ADC result FIFO is full.
>
|
Enumerator |
---|
kADC_HWTriggerMaskDisableMode |
Hardware trigger mask disable and hardware trigger can trigger ADC conversion.
>
|
kADC_HWTriggerMaskAutoMode |
Hardware trigger mask automatically when data fifo is not empty.
>
|
kADC_HWTriggerMaskEnableMode |
Hardware trigger mask enable and hardware trigger cannot trigger ADC conversion.
>
|
void ADC_Init |
( |
ADC_Type * |
base, |
|
|
const adc_config_t * |
config |
|
) |
| |
- Parameters
-
base | ADC peripheral base address. |
config | Pointer to configuration structure. See "adc_config_t". |
void ADC_Deinit |
( |
ADC_Type * |
base | ) |
|
- Parameters
-
base | ADC peripheral base address. |
This function initializes the converter configuration structure with available settings. The default values are as follows.
* config->enableLowPower = false;
* config->enableLongSampleTime = false;
*
- Parameters
-
config | Pointer to the configuration structure. |
static void ADC_EnableHardwareTrigger |
( |
ADC_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ADC peripheral base address. |
enable | Switcher of the hardware trigger feature. "true" means enabled, "false" means not enabled. |
The compare function can be configured to check for an upper or lower limit. After the input is sampled and converted, the result is added to the complement of the compare value (ADC_CV).
- Parameters
-
base | ADC peripheral base address. |
config | Pointer to "adc_hardware_compare_config_t" structure. |
The ADC module supports FIFO operation to minimize the interrupts to CPU in order to reduce CPU loading in ADC interrupt service routines. This module contains two FIFOs to buffer analog input channels and analog results respectively.
- Parameters
-
base | ADC peripheral base address. |
config | Pointer to "adc_fifo_config_t" structure. |
This operation triggers the conversion when in software trigger mode. When in hardware trigger mode, this API configures the channel while the external trigger source helps to trigger the conversion.
- Parameters
-
base | ADC peripheral base address. |
config | Pointer to "adc_channel_config_t" structure. |
bool ADC_GetChannelStatusFlags |
( |
ADC_Type * |
base | ) |
|
- Parameters
-
base | ADC peripheral base address. |
- Returns
- "True" means conversion has completed and "false" means conversion has not completed.
uint32_t ADC_GetStatusFlags |
( |
ADC_Type * |
base | ) |
|
- Parameters
-
base | ADC peripheral base address. |
- Returns
- Flags' mask if indicated flags are asserted. See "_adc_status_flags".
static void ADC_EnableAnalogInput |
( |
ADC_Type * |
base, |
|
|
uint32_t |
mask, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
When a pin control register bit is set, the following conditions are forced for the associated MCU pin: -The output buffer is forced to its high impedance state. -The input buffer is disabled. A read of the I/O port returns a zero for any pin with its input buffer disabled. -The pullup is disabled.
- Parameters
-
base | ADC peripheral base address. |
mask | The mask of the pin associated with channel ADx. Valid range is AD0:0x1U ~ AD15:0x8000U. For example: If enable AD0, AD1 and AD2 pins, mask should be set to 0x7U. |
enable | The "true" means enabled, "false" means not enabled. |
static uint32_t ADC_GetChannelConversionValue |
( |
ADC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | ADC peripheral base address. |
- Returns
- Conversion value.