The customer was able to sample two channels using BURST mode (of 100 samples per trigger) on two channels,
but he was able to reach only a sample rate of 2.5ksps per channel.
The goal is to sample two ADC channels (in parallel as much as possible) and reach at least a sample rate of 11ksps per channel.
BTW, while using only one ADC channel he was able to reach ~60ksps in burst mode with downsamples of 32 and Clock of 2M.
I am sharing the relevant part of his code for reviewing (using ADC CH4 and CH5), Thanks in advance.
int main(void)
{
uint32_t i;
uint32_t data[ADC_BURST_EXAMPLE_NUMBER];
/* Power on ADC */
POWER_EnableADC(true);
/* Initialize board hardware. */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
/* Configure the converter and work mode. */
ADC_Configuration();
float fresult;
while (1)
{
GETCHAR();
/* Start burst */
ADC_Enable(DEMO_ADC_BASE, true);
/* Do software trigger */
ADC_DoSoftwareTrigger(DEMO_ADC_BASE);
for (i = 0; i < ADC_BURST_EXAMPLE_NUMBER; i++)
{
/* Wait for convert complete */
while (!(ADC_GetStatusFlags(DEMO_ADC_BASE) & kADC_DataReadyFlag))
{
}
/* Get the result */
data[i] = (ADC_Type *)DEMO_ADC_BASE->DATA; // ADC_GetConversionResult(DEMO_ADC_BASE);
}
/* Stop burst */
ADC_Enable(DEMO_ADC_BASE, false);
PRINTF("\r\nCH4: \r\n", fresult);
for (i = 0; i < ADC_BURST_EXAMPLE_NUMBER; i++)
{
fresult = ADC_ConversionResult2Mv(DEMO_ADC_BASE, DEMO_ADC_CHANNEL_4, DEMO_ADC_CFG_IDX, g_AdcBandgap,
g_AdcVinn, data[i]);
if (i % 2 == 0)
{
PRINTF("%f\r\n", fresult);
}
}
PRINTF("\r\nCH5: \r\n", fresult);
for (i = 0; i < ADC_BURST_EXAMPLE_NUMBER; i++)
{
fresult = ADC_ConversionResult2Mv(DEMO_ADC_BASE, DEMO_ADC_CHANNEL_5, DEMO_ADC_CFG_IDX, g_AdcBandgap,
g_AdcVinn, data[i]);
if (i % 2 == 1)
{
PRINTF("%f\r\n", fresult);
}
}
}
}
static void ADC_Configuration(void)
{
adc_config_t adcConfigStruct;
adc_sd_config_t adcSdConfigStruct;
/**
* Initial ADC to default configuration.
*/
ADC_GetDefaultConfig(&adcConfigStruct);
adcConfigStruct.channelEnable = (1U << DEMO_ADC_CHANNEL_4) | (1U << DEMO_ADC_CHANNEL_5);
adcConfigStruct.channelConfig = DEMO_ADC_CFG_IDX;
adcConfigStruct.triggerSource = DEMO_ADC_TRIGGER; //the TRIGGER is kADC_TriggerSelectSoftware
adcConfigStruct.convMode = kADC_ConvModeBurstScan;
adcConfigStruct.clock = kADC_Clock2M;
ADC_Init(DEMO_ADC_BASE, &adcConfigStruct);
/* Initial ADC Sigma Delta(SD) configuration */
ADC_GetSdDefaultConfig(&adcSdConfigStruct);
adcSdConfigStruct.downSample = kADC_DownSample32;
ADC_SetSdConfig(DEMO_ADC_BASE, DEMO_ADC_CFG_IDX, &adcSdConfigStruct);
/* Bandgap voltage */
g_AdcBandgap = ADC_GetBandgapCalibrationResult(DEMO_ADC_BASE, DEMO_ADC_CFG_IDX);
/* Calibration VINN value */
g_AdcVinn = ADC_GetVinnCalibrationResult(DEMO_ADC_BASE, &adcConfigStruct);
}
I would appreciate your code review and the support to improve the ADC performance?
In addition, I was thinking that if we use a timer as for ADC trigger (now using software trigger) it might improve ADC performance?
Waiting for your kind response, Thanks a lot.