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
  • 7.60c

    It also seems like after running with debugger, I have to flash again (using flash button) to get it to work again

  • Hi,

    I am not able to reproduce the problem at my end so far. I have a few questions though.

    In the screenshot that you shared, it looks like you are trying the default main file for caf and not the one that you have shared here in the ticket.

    Also, when you say that you are not able to latch separately when using a debugger, do you mean that when you start the debug session, you get this error? or only when you connect an external debugger this problem arises?

    Could you share a zip file of your entire project folder so that I can try to reproduce it here?

    Regards

    Priyanka

  • Yes the screenshot was for before the one I shared.

    The problem is still there if I start a debug session instead of just flashing the nRF52840dk board

    I used the built-in debugger on the board, not an external J-Link

    Board label is: PCA10056, 2.0.2, 2021.43, 683783911

  • Unfortunately the CAF button module does not allow to mention which key should be used for wake up etc. So if you want have a wakeup using only one of the DK buttons, you could try to go back to sleep if all other buttons are pressed.

    -Priyanka

  • 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