Configuring port events to prevent spurious interrupts

Hi Nordic Semiconductor team,

I'm working with the nrf52840 MCU and I have a system off and system on routine and it's works properly (400nA current consumption in system off and 3.3µA in system on). The routine switches to system on when a button is pressed (port event) and I have read that some extra steps are needed to configure the port event.

My question is: Do I need to configure these extra steps for the port event?

Following the previous points (1 to 4), can you give me your opinion? Is this sequence correct?

//======== code ============

//To prevent spurious interrupts
    //1. Disable interrupts
    NRF_GPIOTE->INTENCLR = GPIOTE_INTENSET_PORT_Msk; 
    //2. Configure the sources (sense)
    nrf_gpio_cfg_input(NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(button0), gpios), NRF_GPIO_PIN_PULLUP);
    nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(button0), gpios), NRF_GPIO_PIN_SENSE_HIGH);
    //3. Write 0 to events_port
    NRF_GPIOTE->EVENTS_PORT = 0x00000000; 
   
    //4. Enable interrupts
    NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Enabled;  //<< GPIOTE_INTENSET_PORT_Pos;
    //NVIC_EnableIRQ(GPIOTE_IRQn); //Enable the interrupt
//====================
Thank you in advance.
Regards,
Tania
Parents Reply Children
Related