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 

Parents
  • 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.

  • Not sure how that makes a difference. After deep sleep, the wakeup causes a system reset. And then you should still reconfigure the GPIOs (just to be sure) after the reset caused by wakeup from system off.

  • Yes, the system wakes up after reset, but I cannot always detect which button woke the system. Also, if I set an interrupt handler, sometimes the callback is not called.  When I hold the button down for a longer time (>500ms), everything works

    It seems to be a timing problem. 

    Do you know how much time it takes to reset the nrf52832?

  • When you configure the gpio connected to the button to have sense/detect mechanism that could wake the chip from system off, then after wakeup the device will reset. I do not understand how you expect an interrupt handler to run here from the gpio's activity before the reset happened. 

    Imagine you pressed a button, configured with detect and interrupt enabled. But this interrupt configuration in system off mode will do nothing but wake the chip. When you press the button when your device is in system off mode, no interrupt handlers can run as the only thing your system can do is wake up with a reset. And after the reset, the NVIC inside ARM cortex do not remember that there was an interrupt handler before the reset that was not handled and needs to handle even after the reset. At reset all pending interrupt bits are cleared to reset status.

    I think sometimes when you see your ISR being called could be that it is called after the system wakes up, you still see some debounce on the button which generates new interrupt on the gpio line and causes the ISR to be called after the wakeup. This can only happen if the sequence is like below.

    system_off_enter->press_button.>wakeup_chip->reset->gpiote reconfigured with interrupt callback->debounce from button-> new pin state change causes interrupt-> interrupt callback called.

    And the thing that you do not see this consistently gives me more confidence that what you are seeing is debounce spread over system off.

Reply
  • When you configure the gpio connected to the button to have sense/detect mechanism that could wake the chip from system off, then after wakeup the device will reset. I do not understand how you expect an interrupt handler to run here from the gpio's activity before the reset happened. 

    Imagine you pressed a button, configured with detect and interrupt enabled. But this interrupt configuration in system off mode will do nothing but wake the chip. When you press the button when your device is in system off mode, no interrupt handlers can run as the only thing your system can do is wake up with a reset. And after the reset, the NVIC inside ARM cortex do not remember that there was an interrupt handler before the reset that was not handled and needs to handle even after the reset. At reset all pending interrupt bits are cleared to reset status.

    I think sometimes when you see your ISR being called could be that it is called after the system wakes up, you still see some debounce on the button which generates new interrupt on the gpio line and causes the ISR to be called after the wakeup. This can only happen if the sequence is like below.

    system_off_enter->press_button.>wakeup_chip->reset->gpiote reconfigured with interrupt callback->debounce from button-> new pin state change causes interrupt-> interrupt callback called.

    And the thing that you do not see this consistently gives me more confidence that what you are seeing is debounce spread over system off.

Children
No Data
Related