MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ADC16:Combinational logic inputs Driver

Overview

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc, each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc, for your further reference.

Modules

 ADC16 Peripheral and Driver Overview
 Content including 1) features; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current ADC16 driver version is 2.0.0.
 

Data Structures

struct  adc16_hardware_compare_t
 The structure for configuration the ADC16's hardware compare setting. More...
 
struct  adc16_config_t
 The structure for configuration the ADC16's setting. More...
 

Enumerations

enum  adc16_input_channel_t {
  kADC16_Input0Channel = 0U,
  kADC16_Input1Channel = 1U,
  kADC16_Input2Channel = 2U,
  kADC16_Input3Channel = 3U,
  kADC16_Input4Channel = 4U,
  kADC16_Input5Channel = 5U,
  kADC16_Input6Channel = 6U,
  kADC16_Input7Channel = 7U,
  kADC16_Input8Channel = 8U,
  kADC16_Input9Channel = 9U,
  kADC16_Input10Channel = 10U,
  kADC16_Input11Channel = 11U,
  kADC16_Input12Channel = 12U,
  kADC16_Input13Channel = 13U,
  kADC16_Input14Channel = 14U,
  kADC16_Input15Channel = 15U,
  kADC16_Input16Channel = 16U,
  kADC16_Input17Channel = 17U,
  kADC16_Input18Channel = 18U,
  kADC16_Input19Channel = 19U,
  kADC16_Input20Channel = 20U,
  kADC16_Input21Channel = 21U,
  kADC16_Input22Channel = 22U,
  kADC16_Input23Channel = 23U,
  kADC16_Reserved1 = 24U,
  kADC16_Reserved2 = 25U,
  kADC16_TempSensor = 26U,
  kADC16_ABandgap = 27U,
  kADC16_Reserved3 = 28U,
  kADC16_VREFSH = 29U,
  kADC16_VREFSL = 30U,
  kADC16_ModuleDisabled = 31U
}
 The enumeration all of ADC16 Input channels. More...
 
enum  adc16_clock_divider_t {
  kADC16_ClockDivider1 = 0U,
  kADC16_ClockDivider2 = 1U,
  kADC16_ClockDivider4 = 2U,
  kADC16_ClockDivider8 = 3U
}
 The enumeration ADC16 clock divider. More...
 
enum  adc16_resolution_t {
  kADC16_Resolution8bit = 0U,
  kADC16_Resolution12bit = 1U,
  kADC16_Resolution10bit = 2U,
  kADC16_Resolution16bit = 3U
}
 The enumeration ADC16 Conversion resolution mode. More...
 
enum  adc16_clock_source_t {
  kADC16_ClockSourceAlt0 = 0U,
  kADC16_ClockSourceAlt1 = 1U,
  kADC16_ClockSourceAlt2 = 2U,
  kADC16_ClockSourceAlt3 = 3U,
  kADC16_ClockSourceAsynchronousClock = kADC16_ClockSourceAlt3
}
 The enumeration of ADC16 clock source. More...
 
enum  adc16_sample_mode_t {
  kADC16_SampleCycle24 = 0U,
  kADC16_SampleCycle16 = 1U,
  kADC16_SampleCycle10 = 2U,
  kADC16_SampleCycle6 = 3U,
  kADC16_SampleDisabled = 4U
}
 The enumeration of ADC16 sample mode. More...
 
enum  adc16_compare_mode {
  kADC16_LessThanThreshold = 0U,
  kADC16_GreaterThanOrEqualThreshold = 1U,
  kADC16_TriggerOutsideCompareRangeMode1 = 2U,
  kADC16_TriggerInsideCompareRangeMode1 = 3U,
  kADC16_TriggerInsideCompareRangeMode2 = 4U,
  kADC16_TriggerOutsideCompareRangeMode2 = 5U
}
 The enumeration ADC16 Automatic compare mode. More...
 
enum  adc16_reference_voltage_source_t {
  kADC16_ReferenceVoltageSourceVref = 0U,
  kADC16_ReferenceVoltageSourceValt = 1U,
  kADC16_ReferenceVoltageSourceBandgap = 2U
}
 The enumeration ADC16 Reference voltage source. More...
 
enum  adc16_hardware_average_mode_t {
  kADC16_HardwareAverageCount4 = 0U,
  kADC16_HardwareAverageCount8 = 1U,
  kADC16_HardwareAverageCount16 = 2U,
  kADC16_HardwareAverageCount32 = 3U,
  kADC16_HardwareAverageDisabled = 4U
}
 The enumeration ADC16's Hardware average mode. More...
 
enum  adc16_trigger_source_t {
  kADC16_SoftWareTrigger = 0U,
  kADC16_HardWareTrigger = 1U
}
 The enumeration ADC16’s conversion trigger source. More...
 

Driver version

#define FSL_ADC16_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 ADC16 driver version. More...
 

Initialization

void ADC16_Init (SADC_Type *base, const adc16_config_t *psConfig)
 Initializes the ADC16 module. More...
 
void ADC16_GetDefaultConfig (adc16_config_t *psConfig)
 Gets an available pre-defined settings for the converter's configuration. More...
 
void ADC16_Deinit (SADC_Type *base)
 De-initializes the ADC16 module. More...
 
status_t ADC16_DoAutoCalibration (SADC_Type *base)
 Automates the hardware calibration. More...
 
static void ADC16_SetOffsetValue (SADC_Type *base, int16_t i16Value)
 Sets the offset value for the conversion result. More...
 

Advanced Features

static void ADC16_EnableAssisTrrigger (SADC_Type *base, bool enable)
 Enables assist trigger. More...
 
static void ADC16_EnableDMA (SADC_Type *base, bool enable)
 Enables generating the DMA trigger when the conversion is complete. More...
 
static void ADC16_EnableInterrupt (SADC_Type *base, uint32_t u32GroupId)
 Enables the conversion interrupt . More...
 
static void ADC16_DisableInterrupt (SADC_Type *base, uint32_t u32GroupId)
 Disables the conversion interrupt . More...
 
void ADC16_SetTriggerSource (SADC_Type *base, adc16_trigger_source_t eTriggerSource)
 Settings ADC16 trigger mode. More...
 
void Adc16_DoSoftwareTrigger (SADC_Type *base, uint32_t u32GroupId)
 Turns on the ADC16 conversion . More...
 
void Adc16_AbortSoftwareTrigger (SADC_Type *base, uint32_t u32GroupId)
 Aborts the ADC16 conversion. More...
 
void ADC16_SetHardwareCompareConfig (SADC_Type *base, const adc16_hardware_compare_t *psConfig)
 Configures the hardware compare mode. More...
 
void ADC16_SetHardwareAverage (SADC_Type *base, adc16_hardware_average_mode_t eHardwareAverageMode)
 Sets the hardware average mode. More...
 
void ADC16_ClearCalibrationCompletedFlag (SADC_Type *base)
 Clears calibration completed flag . More...
 

Conversion Channel

void ADC16_AssginChannelToGroup (SADC_Type *base, uint32_t u32GroupId, adc16_input_channel_t eChannel)
 Configures the conversion Group channel. More...
 
static uint32_t ADC16_GetGroupConversionValue (SADC_Type *base, uint32_t u32GroupId)
 Gets the group conversion value. More...
 
bool ADC16_IsGroupConversionCompleted (SADC_Type *base, uint32_t u32GroupId)
 Checks the status of group conversion. More...
 

Data Structure Documentation

struct adc16_hardware_compare_t

Data Fields

adc16_compare_mode eCompareMode
 Select the compare mode. More...
 
int16_t i16Value1
 Setting i16Value1 for hardware compare mode. More...
 
int16_t i16Value2
 Setting i16Value2 for hardware compare mode. More...
 

Field Documentation

adc16_compare_mode adc16_hardware_compare_t::eCompareMode
int16_t adc16_hardware_compare_t::i16Value1
int16_t adc16_hardware_compare_t::i16Value2
struct adc16_config_t

Data Fields

adc16_reference_voltage_source_t eReferenceVoltageSource: 2
 Select the reference voltage source. More...
 
adc16_clock_source_t eClockSource: 3
 Select the input clock source to converter. More...
 
bool bEnableAsynchronousClock: 1
 Enable the asynchronous clock output. More...
 
adc16_clock_divider_t eClockDivider: 3
 Select the divider of input clock source. More...
 
adc16_resolution_t eResolution: 3
 Select the sample resolution mode. More...
 
adc16_sample_mode_t eSampleMode
 Select the sample mode. More...
 
bool bEnableHighSpeed: 1
 Enable the high-speed mode. More...
 
bool bEnableLowPower: 1
 Enable low power. More...
 
adc16_input_channel_t eChannelInput
 Select input channel.
 
uint32_t u32GroupId
 Set group identification, u32GroupId is for Group registers. More...
 
bool bEnableInterruptOnConversionCompleted: 1
 Generate an interrupt request once the conversion is completed. More...
 
adc16_trigger_source_t eConversionTrigger: 2
 Select Conversion Trigger mode. More...
 
bool bEnableDMA: 1
 Enable adc DMA function.
 
bool bEnableContinuousConversion: 1
 Enable continuous conversion mode. More...
 
adc16_hardware_average_mode_t eHardwareAverageMode
 Set hardware average mode. More...
 
adc16_hardware_compare_tpsHardwareCompare
 Set hardware compare mode.
 

Field Documentation

adc16_reference_voltage_source_t adc16_config_t::eReferenceVoltageSource
adc16_clock_source_t adc16_config_t::eClockSource
bool adc16_config_t::bEnableAsynchronousClock
adc16_clock_divider_t adc16_config_t::eClockDivider
adc16_resolution_t adc16_config_t::eResolution
adc16_sample_mode_t adc16_config_t::eSampleMode
bool adc16_config_t::bEnableHighSpeed
bool adc16_config_t::bEnableLowPower
uint32_t adc16_config_t::u32GroupId
bool adc16_config_t::bEnableInterruptOnConversionCompleted
adc16_trigger_source_t adc16_config_t::eConversionTrigger
bool adc16_config_t::bEnableContinuousConversion
adc16_hardware_average_mode_t adc16_config_t::eHardwareAverageMode

Macro Definition Documentation

#define FSL_ADC16_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Enumeration Type Documentation

Enumerator
kADC16_Input0Channel 

AD0 is selected as input.

kADC16_Input1Channel 

AD1 is selected as input.

kADC16_Input2Channel 

AD2 is selected as input.

kADC16_Input3Channel 

AD3 is selected as input.

kADC16_Input4Channel 

AD4 is selected as input.

kADC16_Input5Channel 

AD5 is selected as input.

kADC16_Input6Channel 

AD6 is selected as input.

kADC16_Input7Channel 

AD7 is selected as input.

kADC16_Input8Channel 

AD8 is selected as input.

kADC16_Input9Channel 

AD9 is selected as input.

kADC16_Input10Channel 

AD10 is selected as input.

kADC16_Input11Channel 

AD11 is selected as input.

kADC16_Input12Channel 

AD12 is selected as input.

kADC16_Input13Channel 

AD13 is selected as input.

kADC16_Input14Channel 

AD14 is selected as input.

kADC16_Input15Channel 

AD15 is selected as input.

kADC16_Input16Channel 

AD16 is selected as input.

kADC16_Input17Channel 

AD17 is selected as input.

kADC16_Input18Channel 

AD18 is selected as input.

kADC16_Input19Channel 

AD19 is selected as input.

kADC16_Input20Channel 

AD20 is selected as input.

kADC16_Input21Channel 

AD21 is selected as input.

kADC16_Input22Channel 

AD22 is selected as input.

kADC16_Input23Channel 

AD23 is selected as input.

kADC16_Reserved1 

Reserved.

kADC16_Reserved2 

Reserved.

kADC16_TempSensor 

Temp Sensor (single-ended) is selected as input.

kADC16_ABandgap 

ABandgap (single-ended) is selected as input.

kADC16_Reserved3 

Reserved.

kADC16_VREFSH 

High reference voltage is selected as input.

kADC16_VREFSL 

Low reference voltage is selected as input.

kADC16_ModuleDisabled 

Module is disabled.

Enumerator
kADC16_ClockDivider1 

For divider 1 from the input clock to the module.

kADC16_ClockDivider2 

For divider 2 from the input clock to the module.

kADC16_ClockDivider4 

For divider 4 from the input clock to the module.

kADC16_ClockDivider8 

For divider 8 from the input clock to the module.

Enumerator
kADC16_Resolution8bit 

single-ended 8-bit conversion

kADC16_Resolution12bit 

single-ended 12-bit conversion

kADC16_Resolution10bit 

single-ended 10-bit conversion

kADC16_Resolution16bit 

single-ended 16-bit conversion

Enumerator
kADC16_ClockSourceAlt0 

Selection Bus clock.

kADC16_ClockSourceAlt1 

Selection (Bus clock)/2.

kADC16_ClockSourceAlt2 

Selection Alternate clock (ALTCLK).

kADC16_ClockSourceAlt3 

Selection Asynchronous clock (ADACK).

kADC16_ClockSourceAsynchronousClock 

Using internal asynchronous clock.

Enumerator
kADC16_SampleCycle24 

20 extra ADCK cycles, 24 ADCK cycles total.

kADC16_SampleCycle16 

12 extra ADCK cycles, 16 ADCK cycles total.

kADC16_SampleCycle10 

6 extra ADCK cycles, 10 ADCK cycles total.

kADC16_SampleCycle6 

2 extra ADCK cycles, 6 ADCK cycles total.

kADC16_SampleDisabled 

Disable the sample feature.

Enumerator
kADC16_LessThanThreshold 

Less than threshold.

kADC16_GreaterThanOrEqualThreshold 

Greater than or equal to threshold.

kADC16_TriggerOutsideCompareRangeMode1 

Compare true if the result is less than CV1 Or the result is greater than CV2.

kADC16_TriggerInsideCompareRangeMode1 

Compare true if the result is less than CV1 And the result is greater than CV2.

kADC16_TriggerInsideCompareRangeMode2 

Compare true if the result is greater than or equal to CV1 And the result is less than or equal to CV2.

kADC16_TriggerOutsideCompareRangeMode2 

Compare true if the result is greater than or equal to CV1 Or the result is less than or equal to CV2.

Enumerator
kADC16_ReferenceVoltageSourceVref 

For external pins pair of VrefH and VrefL.

kADC16_ReferenceVoltageSourceValt 

For alternate reference pair of ValtH and ValtL.

kADC16_ReferenceVoltageSourceBandgap 

For bandgap voltage from V BGH and V BGL.

Enumerator
kADC16_HardwareAverageCount4 

For hardware average with 4 samples.

kADC16_HardwareAverageCount8 

For hardware average with 8 samples.

kADC16_HardwareAverageCount16 

For hardware average with 16 samples.

kADC16_HardwareAverageCount32 

For hardware average with 32 samples.

kADC16_HardwareAverageDisabled 

Disable the hardware average feature.

Enumerator
kADC16_SoftWareTrigger 

Software trigger Conversion.

kADC16_HardWareTrigger 

Hardware trigger Conversion.

Function Documentation

void ADC16_Init ( SADC_Type *  base,
const adc16_config_t psConfig 
)
Parameters
baseADC16 peripheral base address.
psConfigPointer to configuration structure.
void ADC16_GetDefaultConfig ( adc16_config_t psConfig)

This function initializes the converter configuration structure with available settings. The default values are as follows.

*
* psConfig->eReferenceVoltageSource = kADC16_ReferenceVoltageSourceVref;
* psConfig->eClockSource = kADC16_ClockSourceAsynchronousClock;
* psConfig->bEnableAsynchronousClock = true;
* psConfig->eClockDivider = kADC16_ClockDivider8;
* psConfig->eResolution = KADC16_Resolution12bit;
* psConfig->eLongSampleMode = kADC16_LongSampleDisabled;
* psConfig->bEnableHighSpeed = false;
* psConfig->bEnableLowPower = false;
* psConfig->eChannelInput = kADC16_ModuleDisabled;
* psConfig->u32GroupId = 0U;
* psConfig->bEnableInterruptOnConversionCompleted = false;
* psConfig->bEnableDMA = false;
* psConfig->eConversionTrigger = kADC16_SoftWareTrigger;
* psConfig->eHardwareAverageMode = kADC16_HardwareAverageDisabled;
* psConfig->bEnableContinuousConversion = false;
* psConfig->psHardwareCompare = NULL;
*
Parameters
psConfigPointer to the configuration structure. See adc16_config_t.
void ADC16_Deinit ( SADC_Type *  base)
Parameters
baseADC16 peripheral base address
status_t ADC16_DoAutoCalibration ( SADC_Type *  base)

This auto calibration helps to adjust the plus/minus side gain automatically. Execute the calibration before using the converter. Note that the hardware trigger should be used during the calibration.

Parameters
baseADC16 peripheral base address.
Returns
Execution status.
Return values
kStatus_SuccessCalibration is done successfully.
kStatus_FailCalibration has failed.
static void ADC16_SetOffsetValue ( SADC_Type *  base,
int16_t  i16Value 
)
inlinestatic

This offset value takes effect on the conversion result. If the offset value is not zero, the reading result is subtracted by it. Note, the hardware calibration fills the offset value automatically.

Parameters
baseADC16 peripheral base address.
i16ValueSetting offset value.
static void ADC16_EnableAssisTrrigger ( SADC_Type *  base,
bool  enable 
)
inlinestatic

This ASSITRGEN register is used to help correctly generate the conversion type. When ASSITRGEN is set, the write to the ADCSC1 COCO bit will be reflected in the ADTRG register, and the operation of ADCSC1 will be delayed by 1/2 cycle.When ASSITRGEN is set, the user must ensure that no hardware trigger occurs when writing ADCSC1 COCO,so that the correct conversion type can be generated when the value of the ADTRG register changes.

Parameters
baseADC16 peripheral base address.
enableSwitcher of the assist trigger feature. "true" means enabled, "false" means not enabled.
static void ADC16_EnableDMA ( SADC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseADC16 peripheral base address.
enableSwitcher of the DMA feature. "true" means enabled, "false" means not enabled.
static void ADC16_EnableInterrupt ( SADC_Type *  base,
uint32_t  u32GroupId 
)
inlinestatic

The u32GroupId is for Group registers. For example,u32GroupId 0 is for Group A registers.

Parameters
baseADC16 peripheral base address.
u32GroupIdgroup identification.
static void ADC16_DisableInterrupt ( SADC_Type *  base,
uint32_t  u32GroupId 
)
inlinestatic

The u32GroupId is for Group registers. For example,u32GroupId 0 is for Group A registers.

Parameters
baseADC16 peripheral base address.
u32GroupIdgroup identification.
void ADC16_SetTriggerSource ( SADC_Type *  base,
adc16_trigger_source_t  eTriggerSource 
)
Parameters
baseADC16 peripheral base address.
eTriggerSourceSetting the trigger conversion mode. See adc16_trigger_source_t.
void Adc16_DoSoftwareTrigger ( SADC_Type *  base,
uint32_t  u32GroupId 
)

The u32GroupId is for Group registers. For example,u32GroupId 0 is for Group A registers.

Parameters
baseADC16 peripheral base address.
u32GroupIdgroup identification.
void Adc16_AbortSoftwareTrigger ( SADC_Type *  base,
uint32_t  u32GroupId 
)

The u32GroupId is for Group registers. For example,u32GroupId 0 is for Group A registers.

Parameters
baseADC16 peripheral base address.
u32GroupIdgroup identification.
void ADC16_SetHardwareCompareConfig ( SADC_Type *  base,
const adc16_hardware_compare_t psConfig 
)

The hardware compare mode provides a way to process the conversion result automatically by using hardware. Only the result in the compare range is available. To compare the range, see "adc16_hardware_compare_mode_t" or the appopriate reference manual for more information.

Parameters
baseADC16 peripheral base address.
psConfigPointer to the "adc16_hardware_compare_config_t" structure. Passing "NULL" disables the feature.
void ADC16_SetHardwareAverage ( SADC_Type *  base,
adc16_hardware_average_mode_t  eHardwareAverageMode 
)

The hardware average mode provides a way to process the conversion result automatically by using hardware. The multiple conversion results are accumulated and averaged internally making them easier to read.

Parameters
baseADC16 peripheral base address.
eHardwareAverageModeSetting the hardware average mode. See adc16_hardware_average_mode_t.
void ADC16_ClearCalibrationCompletedFlag ( SADC_Type *  base)
Parameters
baseADC16 peripheral base address.
void ADC16_AssginChannelToGroup ( SADC_Type *  base,
uint32_t  u32GroupId,
adc16_input_channel_t  eChannel 
)

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.

Note
that the " u32GroupId " has a detailed description. one for each conversion. The u32GroupId parameter indicates which group of registers are used, for example, u32GroupId 0 is for Group A registers. At any point, only one of ,the u32GroupId is actively controlling ADC conversions.The u32GroupId 0 is used for both software and hardware trigger modes. See the chip configuration information in the appropriate MCU reference manual for the number of SC1n registers (u32GroupId) specific to this device. Therefore, writing to these u32GroupId does not initiate a new conversion. Writing any of the u32GroupId registers while that specific u32GroupId is actively controlling a conversion aborts the current conversion.
Parameters
baseADC16 peripheral base address.
u32GroupIdgroup identification. u32GroupId is for Group registers.
eChannelSetting the conversion channel . See adc16_input_channel_t.
static uint32_t ADC16_GetGroupConversionValue ( SADC_Type *  base,
uint32_t  u32GroupId 
)
inlinestatic

The u32GroupId is for Group registers. For example,u32GroupId 0 is for Group A registers.

Parameters
baseADC16 peripheral base address.
u32GroupIdgroup identification.
Returns
Conversion value.
bool ADC16_IsGroupConversionCompleted ( SADC_Type *  base,
uint32_t  u32GroupId 
)

The u32GroupId is for Group registers. For example,u32GroupId 0 is for Group A registers.

Parameters
baseADC16 peripheral base address.
u32GroupIdgroup identification.