Wake up from power off and read saadc for 2 seconds with low latency

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

  • Hello,

    I would say (as a rule of thumb), that it's _only_ if you plan to stay inactive for more than a period of a few minutes, then it may be beneficial to enter system OFF mode, but for other cases it's less average current consumption to stay in normal system ON idle (CPU in sleep running on RTC). The reason is simply that when waking up from system OFF mode you will start from reset, and entire system need to be reconfigured, and for instance startup of the LFCLK source (which can be several hundreds of ms depending on the source).

    Kenneth

  • We are developing a counter application, so roughly 100x wake up per hour can also happen like 1x a day.
    So after the lpcomp event saadc should record as fast as possible.
    How long shoud it take to measure from system off?
    and how long from ON idle?

    Is their something special to consider when going to system off or ON idle if we want to use the saadc after the wakeup?

  • QBSho said:
    So after the lpcomp event saadc should record as fast as possible.

    Then it's only system ON idle that is possible. The wakeup from system OFF can be several tens or hundreds of ms to startup after wakeup due to initialization. This is something you can measure yourself by simple apply wakeup condition and toggle a gpio when you are sampling SSADC.

    Kenneth

Related