adc Samples delivered in wrong order / dropped on ESP32 / continuous read with more than 2 channels

cgn_esp_user
Posts: 1
Joined: Wed Jun 27, 2018 11:32 am

adc Samples delivered in wrong order / dropped on ESP32 / continuous read with more than 2 channels

Postby cgn_esp_user » Mon Jan 30, 2023 3:21 pm

I changed examples/peripherals/adc/continuous_read/main/continuous_read_main.c to use 4 instead of only 2 adc channels.

//static adc_channel_t channel[2] = {ADC_CHANNEL_6, ADC_CHANNEL_7};
static adc_channel_t channel[] = {ADC_CHANNEL_4, ADC_CHANNEL_5, ADC_CHANNEL_6, ADC_CHANNEL_7};

I would expect the program output to be:
I (396) TASK: ret is 0, ret_num is 256
I (396) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: c07
I (396) EXAMPLE: Unit: ADC_UNIT_1, Channel: 5, Value: 8e6
I (416) EXAMPLE: Unit: ADC_UNIT_1, Channel: 6, Value: 28b
I (406) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
I (426) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: ede
I (416) EXAMPLE: Unit: ADC_UNIT_1, Channel: 5, Value: 98b
I (436) EXAMPLE: Unit: ADC_UNIT_1, Channel: 6, Value: 390
I (436) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
...and so on.

However, the samples are delivered in arbitrary, non-constant order like this. (Samples are ordered in a non-reproducible manner, samples are left out/dropped etc..)

I (396) TASK: ret is 0, ret_num is 256
I (396) EXAMPLE: Unit: ADC_UNIT_1, Channel: 5, Value: 8e6
I (396) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: c07
I (406) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
I (416) EXAMPLE: Unit: ADC_UNIT_1, Channel: 6, Value: 28b
I (416) EXAMPLE: Unit: ADC_UNIT_1, Channel: 5, Value: 98b
I (426) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: ede
I (436) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
I (436) EXAMPLE: Unit: ADC_UNIT_1, Channel: 6, Value: 390
I (446) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
I (446) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: fff
I (456) EXAMPLE: Unit: ADC_UNIT_1, Channel: 5, Value: b40
I (466) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: fff
I (466) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
I (476) EXAMPLE: Unit: ADC_UNIT_1, Channel: 6, Value: 561
I (476) EXAMPLE: Unit: ADC_UNIT_1, Channel: 5, Value: c3f
I (486) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: fff
I (496) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
I (496) EXAMPLE: Unit: ADC_UNIT_1, Channel: 6, Value: 643
I (506) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff
I (506) EXAMPLE: Unit: ADC_UNIT_1, Channel: 6, Value: 71b
I (516) EXAMPLE: Unit: ADC_UNIT_1, Channel: 5, Value: e2d
I (526) EXAMPLE: Unit: ADC_UNIT_1, Channel: 4, Value: fff
I (526) EXAMPLE: Unit: ADC_UNIT_1, Channel: 7, Value: fff

It seems that some samples are dropped, some are repeated...

sampling frequency is only 20 k/s, so that should not be an issue.

I know similiar issues have been discussed some time ago, but since then the apis have been completely replaced, so old solutions (if any) will not be usable any more.

Help would be very much appreciated.

Who is online

Users browsing this forum: Bing [Bot] and 79 guests