CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup

I used the Common Application Framework preview sample, with the following additions at end of prj.conf:

# Power management
CONFIG_PM_POLICY_APP=y
CONFIG_CAF_POWER_MANAGER=y
CONFIG_CAF_POWER_MANAGER_TIMEOUT=10
CONFIG_CAF_BUTTONS_PM_EVENTS=y
CONFIG_CAF_LEDS_PM_EVENTS=y

NCS 1.9.1 was used

The nrf52840dk then enters deep sleep after 10 seconds.

When I then perform a button wakeup, by clicking one of the DK buttons, then the GPIO LATCH bits for all 4 buttons are set.

I would expect that only the LATCH bit is set corresponding to the button that was pressed.

Since the LATCH bit is set for all four buttons, this makes it impossible to see the cause of wakeup.

Could this be a bug in the CAF Buttons module?

BTW: This issue was discovered when looking at the case in devzone.nordicsemi.com/.../how-to-detect-gpio-interrupt-source-from-deep-sleep , but using CAF and ncs instead

Parents Reply Children
  • Yes, and my attached project solves this for my purpose, as I can check the cause of wakeup. My application (not shown in the project) will go back to sleep if woken up by the wrong button. This works at least when not debugging (by checking and clearing the GPIO latch register). When debugging, any button wakeup will set the corresponding GPIO latch bit for ALL of the CAF buttons, while if I only flash instead of starting debugging, I can see via the GPIO latch register which button caused the wakeup.

    You can see this by looking at the NRF terminal output:

    1) Here I woke up the board by DK Button 1, not using debugger:

    *** Booting Zephyr OS build v2.7.99-ncs1-1 ***
    [00:00:00.375,671] <inf> main: NRF_P0->LATCH, at wakeup = 0x00000800, after clear = 0x00000000

    As you will see, the latch value marked in GREEN indicates the bit set for DK Button 1

    2) Here I woke up the board by DK Button 4, not using debugger:

    *** Booting Zephyr OS build v2.7.99-ncs1-1 ***
    [00:00:00.380,859] <inf> main: NRF_P0->LATCH, at wakeup = 0x02000000, after clear = 0x00000000

    As you will see, the latch value marked in GREEN indicates the bit set for DK Button 4

     

    3) Here I woke up the board by DK Button 4, and using debugger:

    *** Booting Zephyr OS build v2.7.99-ncs1-1 ***
    [00:00:00.379,150] <inf> main: NRF_P0->LATCH, at wakeup = 0x03001800, after clear = 0x00000000

    As you will see, the latch value marked in RED indicates the bits set for all 4 DK buttons.

    But as I mentioned earlier, this is only a problem when running a debug session.

    You may close this ticket.

Related