Buffer size - ADC continuous mode
Posted: Fri Apr 04, 2025 1:17 pm
Hello, I need help calculating the buffer size in ADC continuous mode.
Let's say I want to read 128 samples for 5 ADC channels (128 x 5 = 640 samples in total).
If I want to store only one conversion frame, should I set MAX_BYTE_RNG as:
or maybe
---
Then, configuring the ADC handle:
When reading the returned buffer:
with MAX_BYTE_RNG = FRAME, I receive a buffer of 128 samples interleaved instead of 640.
with MAX_BYTE_RNG = FRAME*NUM_CHANNEL, I receive a buffer with random number of samples (128,256,640).
Can someone clarify this?
Thank you in advance!
Let's say I want to read 128 samples for 5 ADC channels (128 x 5 = 640 samples in total).
Code: Select all
#define NUM_CHANNELS 5
#define SAMPLES 128
#define FRAME (SAMPLES * sizeof(adc_digi_output_data_t))
Code: Select all
#define MAX_BYTE_RNG FRAME Code: Select all
#define MAX_BYTE_RNG FRAME * NUM_CHANNELS
Then, configuring the ADC handle:
Code: Select all
adc_continuous_handle_cfg_t adc_config;
adc_config.max_store_buf_size = MAX_BYTE_RNG;
adc_config.conv_frame_size = FRAME;
Code: Select all
int max_len = FRAME * NUM_CHANNELS;
esp_err_t ret;
adc_digi_output_data_t result[max_len] = {0};
ret = adc_continuous_read(stream_handle, result, max_len, len_out, 0);
with MAX_BYTE_RNG = FRAME*NUM_CHANNEL, I receive a buffer with random number of samples (128,256,640).
Can someone clarify this?
Thank you in advance!