Max sample rate with ADC in DMA mode

jcolebaker
Posts: 61
Joined: Thu Mar 18, 2021 12:23 am

Max sample rate with ADC in DMA mode

Postby jcolebaker » Wed Nov 15, 2023 7:42 pm

Hi, I am using the ADC in continuous (DMA) mode to read a signal. Ideally we would like to sample at over 1 MS/s.

Using ESP-IDF 4.4.4, with ESP32-WROVER-B module.

I have followed the steps here to set up the ADC controller in DMA mode:
https://docs.espressif.com/projects/esp ... iver-usage

I am using one channel on ADC1 as the input. When calling "adc_digi_controller_configure", I use these options:

Code: Select all

    const adc_digi_configuration_t controller_config =
    {
        .conv_limit_en = true,
        .conv_limit_num = SAMPLE_COUNT,

        .pattern_num = 1,
        .adc_pattern = &pattern_config,

        .sample_freq_hz =  xxx,

        .conv_mode = ADC_CONV_SINGLE_UNIT_1,
        .format = ADC_DIGI_OUTPUT_FORMAT_TYPE1,
    }
    
    // pattern_config defines a single pattern, unit 0, channel 0, bit width 9 or 12, attenuation 11 dB.
I've been sampling 100 or 200 samples and it works well. The documentation indicates that the max sampling frequency is 2 MS/s:

Code: Select all

#define SOC_ADC_SAMPLE_FREQ_THRES_HIGH          (2*1000*1000)
However, with 9 bit resolution, I've found that I can get to about 320 KS/s. Above that, it works but I start to see samples getting repeated in the output, i.e. 2 values at the same level, then a jump to two values at the next level. It looks like the ADC is not finishing fast enough and the previous value is getting copied to RAM again. At 12 bit resolution, I see the same occur at about 270 KS/s.

Is it possible to sample faster than this in DMA mode - i.e. some other configuration I need to change?

Can "conv_mode" be used to obtain a higher sample rate (i.e. by feeding the input to two channels and sampling both at once)? I see options for "ADC_CONV_BOTH_UNIT" and "ADC_CONV_ALTER_UNIT" but it's not clear whether they can be used to obtain higher sample rates. Also, the technical ref manual is confusing about whether ADC2 can be used with DMA - the text says that only ADC1 supports DMA, but the diagrams show both supporting DMA.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 349 guests