ADC in free run

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC in free run

914 Views
pietrodicastri
Senior Contributor II

Good morning

I want to use the ADC in free run. I init a clock as fast as possible for having the fastest speed. For testing the speed I enable the interrupt and I toggle one I/O every tick,. The result on the scope is not what I expect. The rate is very irregular. I don t get the point.

I am using the FRDM for K64. The BUS clock is 60 MHz. The division is 4 so the ADCLK is 15MHz. It should be ok for the 8 bit resolution. 

Is there a suggestion for the irregularity of the interrupt??

Thank You

Labels (1)
Tags (1)
0 Kudos
4 Replies

622 Views
pietrodicastri
Senior Contributor II

Hi Robin,

I am interested in having a look at your project, thank You for the suggestion.

I am now struggling with some urgent delivery. Just a small question. is the processor running

at 120 MHz in the example ?

Thank You

Pietro

0 Kudos

622 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

No. In order to get 18MHz fADCK, I am not using 120MHz core clock in that demo.

I have modify that demo for you to refer: 120MHz Core \ 60MHz Bus \ 15MHz fADCK

fADCK 12MHz 8bit 789kHz.jpg

K64 120MHz.jpg

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

622 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Pietro,

There is another way to observe the ADC conversion rate instead of toggle IO.
Please refer: verify ADC conversion rate with oscilloscope

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

622 Views
pietrodicastri
Senior Contributor II

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

0 Kudos