This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Long button sleep/wakeup

Hi!

I would like to use long button press to send device into sleep mode (using BSP module). Since button is tied to ground, when device goes to sleep mode, and when I release button, there is transition on IO pin, and device goes back from sleep. How can I prevent this?

Thank you!

Parents
  • Hello Sejl

    According to the product specification page 44, the chip is brought out of system off by an active DETECT signal. The DETECT signal is generated when a pin is in the state it is configured to sense. The bsp module uses the app_button library, which in turn uses GPIOTE.

    By default it configures the buttons to detect toggle, this is implemented by the GPIOTE driver by changing the sense configuration for the specific pin whenever the DETECT signal triggers. So as you push the button, the pin it is connected to goes low, which triggers a low-to-high transition of the DETECT signal. The GPIOTE driver then changes the polarity, causing the DETECT signal to go low again, and then executes the specified handlers. Now your button is specified to generate a DETECT signal on a high input, which is what you get when you release the button.

    You could try use bsp_buttons_disable() and bsp_wakeup_button_enable before you initiate sleep. The first function disables sense for all buttons, and the second enables sensing for the state defined as active state in pca10028.h (Low state).

    Edit: I realized this wouldn't work properly if your designated wake-up pin is the same as the pin you use to put it to sleep as the button would naturally have a high DETECT signal since you're holding it down. You would then need to wait to initate the sleep until you have released the button, or use different buttons for sleep and wake.

    Best regards

    Jørn Frøysa

  • Yet another possibility, as described in this post is to use the low power comparator to trigger a wake-up signal on high to low transition. That way you can simply disable sensing of the pin, and configure the LPCOMP. This will allow the chip to go to sleep, as the DETECT signal will now be low, and releasing the button will not affect it.

Reply Children
No Data
Related