How is it used? And why to use it?
static nrf_saadc_value_t m_buffer_pool[2][SAMPLES_IN_BUFFER];
instead of
static nrf_saadc_value_t m_buffer[SAMPLES_IN_BUFFER];
How is it used? And why to use it?
static nrf_saadc_value_t m_buffer_pool[2][SAMPLES_IN_BUFFER];
instead of
static nrf_saadc_value_t m_buffer[SAMPLES_IN_BUFFER];
Hi,
The SAADC peripheral support double buffering. When the first buffer is filled, conversion to the second buffer is started, which allows you to do processing on the values in the buffer without interrupting the conversion.
The two buffers are setup for conversion like this:
nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
nrf_saadc_value_t m_buffer_pool[2]
is just an array holding both buffers used. You could just as well have declared two individual buffers:
static nrf_saadc_value_t m_buffer_pool_1[SAMPLES_IN_BUFFER];
static nrf_saadc_value_t m_buffer_pool_2[SAMPLES_IN_BUFFER];
and set them up for conversion like this:
nrf_drv_saadc_buffer_convert(m_buffer_pool_1, SAMPLES_IN_BUFFER);
nrf_drv_saadc_buffer_convert(m_buffer_pool_2, SAMPLES_IN_BUFFER);
If you do not need double buffering, you only need to declare and setup one buffer for conversion.
Best regards,
Jørgen
Hi,
The SAADC peripheral support double buffering. When the first buffer is filled, conversion to the second buffer is started, which allows you to do processing on the values in the buffer without interrupting the conversion.
The two buffers are setup for conversion like this:
nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
nrf_saadc_value_t m_buffer_pool[2]
is just an array holding both buffers used. You could just as well have declared two individual buffers:
static nrf_saadc_value_t m_buffer_pool_1[SAMPLES_IN_BUFFER];
static nrf_saadc_value_t m_buffer_pool_2[SAMPLES_IN_BUFFER];
and set them up for conversion like this:
nrf_drv_saadc_buffer_convert(m_buffer_pool_1, SAMPLES_IN_BUFFER);
nrf_drv_saadc_buffer_convert(m_buffer_pool_2, SAMPLES_IN_BUFFER);
If you do not need double buffering, you only need to declare and setup one buffer for conversion.
Best regards,
Jørgen