In our project we want to trigger the saadc with the lp_comp and read Analog input once for 2s (with 2000 Samples).
In the lp_comp_handler we call:
status = nrfx_saadc_buffer_set(m_sample_buffers[0], BUFFER_SIZE); status = nrfx_saadc_mode_trigger();
We have set the Sample frequency to 1kHz and the Buffer size 2000. But it seems that the buffer holds data from 200ms not the expected 2000ms.
1. Is their something wrong in my configuration?
#define CH0_AIN ANALOG_INPUT_TO_SAADC_AIN(ANALOG_INPUT_A1) #define ACQ_TIME_10K 40UL #define CONV_TIME 2UL #define INTERNAL_TIMER_FREQ 1000000UL #define SAADC_SAMPLE_FREQUENCY 1000UL #define INTERNAL_TIMER_CC (INTERNAL_TIMER_FREQ / SAADC_SAMPLE_FREQUENCY) #define BUFFER_COUNT 1UL #define BUFFER_SIZE 2000UL #define SAMPLING_ITERATIONS 1UL static void saadc_init(void){ nrfx_err_t status; (void)status; status = nrfx_saadc_init(NRFX_SAADC_DEFAULT_CONFIG_IRQ_PRIORITY); NRFX_ASSERT(status == NRFX_SUCCESS); #if defined(__ZEPHYR__) IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SAADC), IRQ_PRIO_LOWEST, nrfx_saadc_irq_handler, 0); #endif m_single_channel.channel_config.gain= NRF_SAADC_GAIN1_4; m_single_channel.channel_config.reference= NRF_SAADC_REFERENCE_VDD4; status = nrfx_saadc_channel_config(&m_single_channel); NRFX_ASSERT(status == NRFX_SUCCESS); nrfx_saadc_adv_config_t adv_config = NRFX_SAADC_DEFAULT_ADV_CONFIG; adv_config.internal_timer_cc = INTERNAL_TIMER_CC; adv_config.start_on_end = false; uint32_t channel_mask = nrfx_saadc_channels_configured_get(); status = nrfx_saadc_advanced_mode_set(channel_mask, NRF_SAADC_RESOLUTION_14BIT, &adv_config, saadc_handler); NRFX_ASSERT(status == NRFX_SUCCESS); status = nrfx_saadc_buffer_set(m_sample_buffers[0], BUFFER_SIZE); NRFX_ASSERT(status == NRFX_SUCCESS); m_saadc_done = true; status = nrfx_saadc_offset_calibrate(saadc_handler); }
It also seems to be a quite big latency ( ~200ms) before the saadc starts to read data to the buffer (even when not powered off). We need data as fast as possible after lp_comp interrupt.
2. Is another mode faster than advanced non-blocking?
3. How fast is the saadc ready after power off mode and lp_comp interrupt?
SDK Version 2.5.2
Hardware RAK4630 NRF52840