This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Wakeup from sleep with GPIO

Hi, I would like to put a nrf51822 device into system off mode and wake it up with a GPIO transition from high to low. I would like to measure the press time of the button after wake up but it seems that software doesn't run properly until the button is pressed. So, does the software run normally after the reset transition even if the button is still pressed? I hope it is clear. Thanks.

  • Well the software doesn't run properly until the button is pressed because it's off. After you press the button and the chip resets then of course it will run normally, from the very start of your code. If you want to measure the press time of the button, then you'll have to detect at the start of your code if the button is currently pressed and start timing it, and you'll miss the time it takse for the system to reset itself.

  • Hi, thanks for your reply. Of course the software doesn't run in system off mode. Anyway, the pin is configured to wake up the device at a low level. I use a timer for measuring the press time from the beginning of the software. Now, when I press the button (transition from high to low) it seems that the software doesn't run until the button is released (transition low to high). So, at the first button press nothing happens while at the second press I can measure a press successfully. So, does the software resets and runs after the first transition high to low (with level remaining at low level) or the software starts running at the next low to high transition? Thanks.

  • Well the system is off so there is no software running to detect the first button transition, so you only detect the second button transition. So, if you want to time the transition which also caused the chip to come out of reset, you need to check the state of the button right at the start of your code and start timing if it's low. For subsequent presses, when the system is running, the transition will be captured.

  • Hi, yes, I do exactly as you said. The timer starts running after reset immediately is level is low. Anyway, can you confirm that software runs after the wake up transition even if it still at low? Thanks.

  • I no-longer really understand what you're asking. I can't confirm if the software runs after wake up, it's your code. You say the timer starts running after reset if the level is low, so that would mean that it's running. If you have the wake up configured correctly then the first press will wake the chip up and start your code. So if you're not seeing that, either you have the wake up configured incorrectly and the chip doesn't wake until the second button press, or you have a problem in your code which doesn't actually start the timer running on reset if the pin is low even though it's supposed to. All I can say is that the chip will reset on whatever GPIO event you have configured to wake it up and it will then instantly start running whatever code you have on it.

Related