AnsweredAssumed Answered

why does it take so long to retrieve the ADC conversion result?

Question asked by chronopoulos.chris@gmail.com on Jul 10, 2018

i'm using the ADC on the QN9080-DK, and found that i can't sample it faster than about 500 Hz, because these three lines:

 

ADC_DoSoftwareTrigger(ADC);
while (!(ADC_GetStatusFlags(ADC) & kADC_DataReadyFlag)) {}
adcConvResult = ADC_GetConversionResult(ADC);

 

are taking 2 ms to complete (i tested this by toggling a GPIO pin before and after execution, and measuring the duration of the pulse with an oscilloscope). actually i find that the first 2 lines only take 12 microseconds, and it's the third line that takes 2 ms. why is the call to ADC_GetConversionResult() taking so long?

 

here's my ADC configuration:

 

POWER_EnableADC(true);

adc_config_t adcConfigStruct;
adc_sd_config_t adcSdConfigStruct;

/* Initial ADC to default configuration */
ADC_GetDefaultConfig(&adcConfigStruct);
adcConfigStruct.channelEnable = (1U << ADC_CHANNEL);
adcConfigStruct.channelConfig = (ADC_CFG_IDX << ADC_CHANNEL);
adcConfigStruct.triggerSource = kADC_TriggerSelectSoftware;
adcConfigStruct.convMode = kADC_ConvModeSingle;
adcConfigStruct.clock = kADC_Clock2M;
adcConfigStruct.dataFormat = kADC_ForceUnsigned;
ADC_Init(ADC, &adcConfigStruct);

/* Initial ADC Sigma Delta(SD) configuration */
ADC_GetSdDefaultConfig(&adcSdConfigStruct);
ADC_SetSdConfig(ADC, ADC_CFG_IDX, &adcSdConfigStruct);

/* Enable ADC */
ADC_Enable(ADC, true);

Outcomes