Page 1 of 1

async analogRead

Posted: Mon Jan 11, 2021 9:13 am
by kendo55
in both adc ESP-IDF-exaples,
https://github.com/espressif/esp-idf/bl ... ple_main.c
we have a sync read of the adc value.
and therefor we loss a lot of cpu time!

Code: Select all

r = adc2_get_raw( ADC2_EXAMPLE_CHANNEL, width, &read_raw);
do we have a way to start the conversion,
and then to polling or better, have a interrupt, if the conversion is done.


My research has shown there was an attempt at the "arduino-esp32" version (2017).
This has been removed in the meantime

https://github.com/espressif/arduino-esp32/issues/220

My preferred solution would be, if we had a DMA supported adc.
Automatic continues adc (with cycle time, and number of chanels, as a parameters) via DMA. Independent from the CPU.
The only CPU time we use, is , to read the memory area that was written to by the DMA.
This is realised, on STM32 CPU's since about ten years!

Re: async analogRead

Posted: Fri Aug 25, 2023 7:59 pm
by mggarland
Hi,

Just Wonder if you ever got to the bottom of this?

An interrupt driven return would be ideal in my scenario.

Thanks

Re: async analogRead

Posted: Sat Aug 26, 2023 1:50 am
by ESP_Sprite
FWIW, all ESP32 chips have the capability to do DMA-based ADC reads. The ESP32 does it via the I2S peripheral; later chips have a standalone DMA implementation.