This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52 wakeup time

Hi,

what is the typical or max wake up time of the nRF52 from the RTC or GPIOTE irq (when configured as sense for low level input)?

In my setup, I see a wakeup time of ~13usec from the moment that the nRF52 current consumption is increasing, till the time the RTC irq handler is running.

RTC is running from an external crystal.

Normally I would expect the following wakeup delays till the start of RTC irq handler:

tSTART_HFINT Startup time: 3us

tIDLE2CPU Time from IDLE to CPU execute: 3us

What is the reason that I see 13us and not 6us till the RTC handler starts to execute code?

The wakup time from an external GPIO sense low event that I measure is ~16us.

Regards

Thanassis

Parents
  • Hi Thanassis

    tSTART_HFINT startup time refers to the internal 64MHz oscillator, so when you are running on an external oscillator it nothing out of the normal that the startup time increases somewhat, actually I am surprised the startup delay isn't longer. To get closer to the what the PS states you can try to use the internal oscillator (HFINT).

    Best regards,

    Simon

Reply
  • Hi Thanassis

    tSTART_HFINT startup time refers to the internal 64MHz oscillator, so when you are running on an external oscillator it nothing out of the normal that the startup time increases somewhat, actually I am surprised the startup delay isn't longer. To get closer to the what the PS states you can try to use the internal oscillator (HFINT).

    Best regards,

    Simon

Children
  • Hi Simon,

    many thanks for your response.

    I am using the internal 64Mhz as nRF52 clock.

    As a LFCLK I am using an external 32.768Khz crystal which drives the RTC.

    So I was expecting to see tSTART_HFINT: 3us for the HFINT startup + tIDLE2CPU: 3us for the

    IDLE to CPU execute, but I see +10us till the irq handler is executed.

    In the bellow example, you could see a clearer wakeup sequence from an external GPIO signal.

     

    Is there anything else that I can do to reduce the extra 10us from my wake up time?

    Another question is what is the reason that it takes so long for the nRF52 to go to sleep again after a WFI command.

    The code used for the above example is the following:

    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include "nrf.h"
    #include "nrf_gpio.h"
    
    //==============================================================================
    
    
    #define GPIO_WAKEUP_PIN             2
    #define GPIO_IRQ_PIN                4
    #define NRF_WAKEUP_SHOW_PIN         28 
    
    //==============================================================================
    //==============================================================================
    
    void GPIOTE_IRQHandler(void)
    {
        nrf_gpio_pin_set(GPIO_IRQ_PIN);
        
        if(NRF_GPIOTE->EVENTS_PORT)
        {
            if(NRF_P0->LATCH & ( 1 << GPIO_WAKEUP_PIN))
            {
                NRF_P0->LATCH = 1 << GPIO_WAKEUP_PIN;
            }
           
            NRF_GPIOTE->EVENTS_PORT = 0;
        }
        nrf_gpio_pin_clear(GPIO_IRQ_PIN);
    }
    
    //==============================================================================
    int main(void)
    {
    //    interrupts_disable();
        
        // enable Instruction Cache
        NRF_NVMC->ICACHECNF |= NVMC_ICACHECNF_CACHEEN_Enabled << NVMC_ICACHECNF_CACHEEN_Pos;
        // enable Instruction Cache profiling
        // check NRF_NVMC->IHIT, NRF_NVMC->IMISS registers for i-cache analysis
        NRF_NVMC->ICACHECNF |= NVMC_ICACHECNF_CACHEPROFEN_Enabled << NVMC_ICACHECNF_CACHEPROFEN_Pos;
    
        //enable the DCDC converter
        NRF_POWER->DCDCEN = 1;
        //use the low power mode
        NRF_POWER->TASKS_LOWPWR = 1;
    
    
        // setup gpio sense pin
        NRF_GPIO->LATCH = (1<< GPIO_WAKEUP_PIN); //clear any latched DETECT
        NRF_GPIOTE->EVENTS_PORT = 0;
        nrf_gpio_cfg_sense_input(GPIO_WAKEUP_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
        NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
        NVIC_ClearPendingIRQ(GPIOTE_IRQn);
        NVIC_SetPriority(GPIOTE_IRQn, 6);  
        NVIC_EnableIRQ(GPIOTE_IRQn);
        
        nrf_gpio_cfg_output(GPIO_IRQ_PIN);
        nrf_gpio_cfg_output(NRF_WAKEUP_SHOW_PIN);
        nrf_gpio_cfg_output(RTC_IRQ_PIN);
    
        __enable_irq();
        
        while (true)
        {
            nrf_gpio_pin_clear(NRF_WAKEUP_SHOW_PIN);
            
            __WFI();
            
            nrf_gpio_pin_set(NRF_WAKEUP_SHOW_PIN);
            
        }
    }
    //==============================================================================
    

Related