Good moirning
I would like to have a support. I dump here a view of the code I use.https://community.nxp.com/community/kinetis
/**
The code for the adc
*/
static void ADC16_Configuration(void)
{
adc16_config_t adcUserConfig;
adc16_channel_config_t adc16ChannelConfigStruct;
/*
* Initialization ADC for 16bit resolution, DMA mode, normal convert speed, VREFH/L as reference,
* enable continuous convert mode.
*/
ADC16_GetDefaultConfig( &adcUserConfig );
adcUserConfig.referenceVoltageSource = kADC16_ReferenceVoltageSourceVref;
adcUserConfig.clockSource = kADC16_ClockSourceAlt0;
adcUserConfig.enableAsynchronousClock = true;
adcUserConfig.clockDivider = kADC16_ClockDivider4;
adcUserConfig.resolution = kADC16_ResolutionSE8Bit;
adcUserConfig.longSampleMode = kADC16_LongSampleDisabled;
adcUserConfig.enableHighSpeed = true;
adcUserConfig.enableLowPower = false;
adcUserConfig.enableContinuousConversion = true;
// adcUserConfig.resolution = kADC16_Resolution16Bit;
// adcUserConfig.clockSource = kADC16_ClockSourceAsynchronousClock;
// adcUserConfig.enableLowPower = true;
#if ((defined BOARD_ADC_USE_ALT_VREF) && BOARD_ADC_USE_ALT_VREF)
adcUserConfig.referenceVoltageSource = kADC16_ReferenceVoltageSourceValt;
#endif
ADC16_Init( DEMO_ADC16_BASEADDR, &adcUserConfig );
ADC16_EnableHardwareTrigger( DEMO_ADC16_BASEADDR, false );
#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
/* Auto calibration */
if ( kStatus_Success == ADC16_DoAutoCalibration( DEMO_ADC16_BASEADDR ) )
{
}
else
{
}
#endif
/* Enable software trigger. */
ADC16_EnableHardwareTrigger( DEMO_ADC16_BASEADDR, false );
adc16ChannelConfigStruct.channelNumber = DEMO_ADC_USER_CHANNEL;
adc16ChannelConfigStruct.enableInterruptOnConversionCompleted = true; /* Enable the interrupt. */
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
adc16ChannelConfigStruct.enableDifferentialConversion = false;
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
/* Disable DMA. */
ADC16_EnableDMA( DEMO_ADC16_BASEADDR, false );
INT_SYS_EnableIRQ( ADC0_IRQn );
ADC16_SetChannelConfig( DEMO_ADC_BASE, DEMO_ADC_CHANNEL_GROUP, &adc16ChannelConfigStruct );
}
/*
* The interrupt handler . Just does nothing than toggling the I/O for the scope
*/
void DEMO_ADC_IRQ_HANDLER(void)
{
toggle();
/* Read to clear COCO flag. */
int32_t g_AdcConvValue = ADC16_GetChannelConversionValue(DEMO_ADC_BASE, DEMO_ADC_CHANNEL_GROUP);
/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
exception return operation might vector to incorrect interrupt */
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
}
Thank You