Detect click and double click after deep sleep

Hello

  When nrf52832 wakes up from a deep sleep, some times calling nrf_gpio_pin_latch_get does not return the button in pressed state. Perhaps it is some timing issue.

  I would like to know what is the best way to detect a simple or a  double click when waking from a deep sleep;

  Thank you in advance 

  • Hi Marcelo

    But the device does indeed wake up every time you press a button, correct, even though the nrf_gpio_pin_latch_get  does not return the correct button state always. My guess is that the reason you're seeing the incorrect button state is because of debouncing, so at the time of reading the button state, the button is read as being in the incorrect state because it is "bouncing back" from the pressed state (or unpressed state). I'm not sure what SDK you're working on, but the button handling library in the nRF5 SDK for example has a button handler that also handles debouncing so that the correct value of a button will be reported every time.

    Best regards,

    Simon

  • Thank you Simonr!

    I am suspecting timing issues as well.
    Do you happen to know if there is a default pre-defined debounce interval?

    I am asking because sometimes, mostly, I am not able to detect when the button is pressed. Additionally, also  the interrupt handler is frequently not called. 

    Rgds

  • Hi

    In the nRF5 SDK the app_button_init() sets a detection delay which by default in our samples is set to be APP_TIMER_TICKS(50) which is 50 in number of timer ticks.

    Best regards,

    Simon

  • I am using Zephyr, and even with interrupts enabled, I am sometimes experiencing issues where interrupt requests are not being handled as expected. Specifically, I have observed that the interrupt handler is not being called when an interrupt occurs, and as a result, important tasks are not being executed in a timely manner. This behavior seems to occur sporadically, and I have been unable to determine a specific pattern or trigger for when it happens.

    Best regards, Marcelo

  • Marcelo,

    I am assuming you have tried to use v2.2.0\zephyr\samples\basic\button sample to test your button. It is very strange behavior that you say that interrupt requests are not being handled as expected. Can you elaborate more on that? 

    The LATCH feature only works when you have enabled the SENSE functionality in the GPIO which would enable the DETECT signal required for the latch register to function correctly.

    I am assuming that you have configured the SENSE in PIN_CNF[X] register and that in your code when you read the latch register you always clear it to "0". The button feature works properly on DK, so it must either be a configuration issue or some other capacitance issue on your board.

Related