Microcontroller doesn't wake up sometimes with external pins

Hi, I am using 4 external pins to wakeup the nRF5340 microcontroller when this goes into deep sleep. There are 2 pins from two buttons, one pin from an interrupt of microcontroller and the last one it is the PGOOD pin of a battery charger.

The code works most of the time, but sometimes the wakeup doesn't work and the device goes into zombie mode.

The code is the following:

        nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(BUTTON1_NODE,gpios),NRF_GPIO_PIN_SENSE_LOW);
        nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(BUTTON2_NODE,gpios),NRF_GPIO_PIN_SENSE_LOW);
        nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(PGOOD_NODE,gpios),NRF_GPIO_PIN_SENSE_HIGH);

        // Read pins until the default state is correct
        // https://devzone.nordicsemi.com/f/nordic-q-a/88124/using-nfc-pin-p0-10-as-wake-up-pin-in-nrf52833

        // Enter into low-power mode
        // Above we disabled entry to deep sleep based on duration of
        // controlled delay.  Here we need to override that, then
        // force entry to deep sleep on any delay.
        pm_state_force(0,&(struct pm_state_info){PM_STATE_SOFT_OFF,0,0});
        // Now we need to go sleep. This will let the idle thread runs and
        // the pm subsystem will use the forced state. To confirm that the
        // forced state is used, lets set the same timeout used previously.
        k_sleep(K_SECONDS(2));

        while(true);

Can you give me some suggestion to solve the issue?

Best

Marco

Parents Reply Children
No Data
Related