Open ermacv opened 2 weeks ago
I'll take a look.
Hello! I still cannot create 100% reproducible test app but I have some extra results.
I included private headers to the source file and read the number of ADC internal ring buffer items before starting a new ADC conversion. The code:
UBaseType_t uxItemsWaiting;
vRingbufferGetInfo(adc1_handle->ringbuf_hdl, NULL, NULL, NULL, NULL, &uxItemsWaiting);
if (uxItemsWaiting != 0) {
ESP_LOGW(TAG, "uxItemsWaiting = %u", uxItemsWaiting);
}
ESP_ERROR_CHECK(adc_continuous_config(adc1_handle, &config));
ESP_ERROR_CHECK(adc_continuous_start(adc1_handle));
...
And when the assertion is fired I also see the following log:
W (615) plat_analog: uxItemsWaiting = 256
W (615) plat_analog: channel = 7, p->type2.channel = 6
So it seems that calling:
ESP_ERROR_CHECK(adc_continuous_stop(adc1_handle));
ESP_ERROR_CHECK(adc_continuous_flush_pool(adc1_handle));
after successful adc_continuous_read
is not enough and data are pushed to the ring buffer from ISR handler.
Wow! I have more interesting results! I modified the read code:
UBaseType_t uxItemsWaiting;
vRingbufferGetInfo(adc1_handle->ringbuf_hdl, NULL, NULL, NULL, NULL, &uxItemsWaiting);
if (uxItemsWaiting != 0) {
ESP_LOGW(TAG, "uxItemsWaiting (before adc_continuous_config) = %u", uxItemsWaiting);
}
ESP_ERROR_CHECK(adc_continuous_config(adc1_handle, &config));
ESP_ERROR_CHECK(adc_continuous_start(adc1_handle));
static uint8_t buf[NO_OF_SAMPLES * SOC_ADC_DIGI_DATA_BYTES_PER_CONV];
uint32_t out_length;
ESP_ERROR_CHECK(adc_continuous_read(adc1_handle, buf, sizeof(buf), &out_length, ADC_MAX_DELAY));
assert(out_length == sizeof(buf));
ESP_ERROR_CHECK(adc_continuous_stop(adc1_handle));
ESP_ERROR_CHECK(adc_continuous_flush_pool(adc1_handle));
vTaskDelay(0);
vRingbufferGetInfo(adc1_handle->ringbuf_hdl, NULL, NULL, NULL, NULL, &uxItemsWaiting);
if (uxItemsWaiting != 0) {
ESP_LOGW(TAG, "uxItemsWaiting (after adc_continuous_flush_pool) = %u", uxItemsWaiting);
}
And I observe this log (after several attempts):
W (1606) plat_analog: uxItemsWaiting (after adc_continuous_flush_pool) = 256
W (1616) plat_analog: uxItemsWaiting (before adc_continuous_config) = 256
W (1626) plat_analog: channel = 6, p->type2.channel = 0
So it means that ADC HW could sometimes generate an interrupt even after adc_continuous_stop
call and it is the reason why ring buffer is filled on plat_analog_get_voltage
new function call.
Answers checklist.
IDF version.
v5.3.1
Espressif SoC revision.
ESP32-S3
Operating System used.
Windows
How did you build your project?
Command line with CMake
If you are using Windows, please specify command line type.
None
Development Kit.
Custom Board
Power Supply used.
USB
What is the expected behavior?
I expect that ADC in continuous mode returns valid
channel
inadc_digi_output_data_t
structure.What is the actual behavior?
ADC in continuous mode sometimes returns invalid
channel
inadc_digi_output_data_t
structure.Steps to reproduce.
Hello!
I read an ADC channel in continuous mode using the following function
plat_analog_get_voltage
. Sometimes I got assertion failed on lineassert(channel == p->type2.channel);
. The functionplat_analog_get_voltage
is called in polling task several times (~10) and then the task is sleep for 100 ms. The assertion could be triggered just after device boot and after few hours, so I don't know how to reproduce it correctly. Theplat_analog_init
is called only on device boot.Debug Logs.
More Information.
No response