Understanding ADC Continuous Mode Configuration in ESP32S2 Using IDF-5.1.1
Posted: Fri Sep 22, 2023 7:15 am
Using ESP32S2 with IDF-5.1.1, I am performing continuous readings on 3 ADC channels.
According to the description in adc_continuous.h, conv_frame_size needs to be a multiple of SOC_ADC_DIGI_DATA_BYTES_PER_CONV, i.e., a multiple of 2.
I set conv_frame_size to channl * SOC_ADC_DIGI_DATA_BYTES_PER_CONV, which is 3 * 2. However, an error occurs.
In adc_hal.c, there is an assertion that requires it to be a multiple of 4.
So, I tried changing the conv_frame_size from the previous 6 to 8, and the error no longer occurs.
Is the statement in adc_continuous.h incorrect, or have I misunderstood something?
According to the description in adc_continuous.h, conv_frame_size needs to be a multiple of SOC_ADC_DIGI_DATA_BYTES_PER_CONV, i.e., a multiple of 2.
Code: Select all
adc_continuous.h
/**
* @brief ADC continuous mode driver initial configurations
*/
typedef struct {
uint32_t max_store_buf_size; ///< Max length of the conversion Results that driver can store, in bytes.
uint32_t conv_frame_size; ///< Conversion frame size, in bytes. This should be in multiples of `SOC_ADC_DIGI_DATA_BYTES_PER_CONV`.
} adc_continuous_handle_cfg_t;
In adc_hal.c, there is an assertion that requires it to be a multiple of 4.
Code: Select all
adc_hal.c:
static void adc_hal_digi_dma_link_descriptors(dma_descriptor_t *desc, uint8_t *data_buf, uint32_t per_eof_size, uint32_t eof_step, uint32_t eof_num)
{
HAL_ASSERT(((uint32_t)data_buf % 4) == 0);
HAL_ASSERT((per_eof_size % 4) == 0);
}
Is the statement in adc_continuous.h incorrect, or have I misunderstood something?