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);
Hi Chris,
I tried to replicate the issue by configuring the ADC as you did, but I actually was able to sample faster than 500 Hz (1 kHz and 2 kHz with no problem).
As you can see the only difference is that I didn't use the software trigger, I used the CTIMER instead to trigger the ADC. The timer configuration is the following:
My best guess is that some other area of your code is causing this issue, I recommend you to try the example I used from the SDK (adc interrupt) adding the timer config and see if you get the same problem.
Best regards,
Felipe.