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

System off wakeup by release of key

Hello,

 I am developing a  remote device which uses system off mode for idle state. I also have the condition where extra long press of any key that is beyond the long press timeout will force device to enter in system off mode. But due to this i am facing auto wakeup from system off which i dont want .So I found that any signal change to gpio pin that may be low to high or high to low is detect signal for that GPIO which is causing reset. My question is that Can we identify that system got wakeup due to press event or release event. ?

Gpio configuration used is

 

static void buttons_init(void)
{
    ret_code_t err_code;

    //The array must be static because a pointer to it will be saved in the button handler module.
    static app_button_cfg_t buttons[] =
    {
        {PAGE_SEL_KEY, false, BUTTON_PULL, button_event_handler},
    };

    err_code = app_button_init(buttons, ARRAY_SIZE(buttons),
                               BUTTON_DETECTION_DELAY);
    APP_ERROR_CHECK(err_code);
    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);
}

Thanks and regards.

  • RESETREAS will only tell you that the reset was triggered by a pin reset.

    You can, however, specify the sense e.g. release or press, of the pin used to trigger the wakeup with nrf_gpio_cfg_sense_set(), but I suspect that you've probably already done that.

    Another option is to check the time that a button has been pressed for, but don't trigger the shutdown into SYSTEM OFF until after the button has been released. 

  • Another option is to check the time that a button has been pressed for, but don't trigger the shutdown into SYSTEM OFF until after the button has been released.

    We need very low current consumption also as it is the product requirement i cant do this.

    You can, however, specify the sense e.g. release or press, of the pin used to trigger the wakeup with nrf_gpio_cfg_sense_set(), but I suspect that you've probably already done that.

    Yes i am already doing this but no luck.

    I am now trying to store key press data to flash memory as it can read out on every reset  condition. 

    Please suggest me if there is another way.

  • cbd said:
    Another option is to check the time that a button has been pressed for, but don't trigger the shutdown into SYSTEM OFF until after the button has been released. 

    I think that is the way to go, I do not see how that should affect current consumption (since the time can be measured with RTC) unless the user repeatedly go to system OFF.

  • I'd be wary of storing key press data in flash as you'll be limiting the life of your flash and also drawing more current in order to write and erase data than you would potentially save.

    I also don't see how it would get you around your issue as you would still react to the reset and then have to check flash value, GPIO value before trying to shutdown and the cycle would then potentially start over again again.

    You can't set the sense of the GPIO detection if the GPIO line is already in that state as you will immediately get a detection trigger (from 52840 datasheet, but will be applicable to other MCUs):

    Make sure that a pin is in a level that cannot trigger the sense mechanism before enabling it. The DETECT
    signal will go high immediately if the SENSE condition configured in the PIN_CNF registers is met when the
    sense mechanism is enabled. This will trigger a PORT event if the DETECT signal was low before enabling
    the sense mechanism.

    Hence my suggestion of waiting until the button is released before triggering SYSTEM OFF.

    I see that you are using the button app library code, so there is no reason why you can't capture time of button press and then time of button release in your button event handler. If the difference is greater than your long button press you can then trigger SYSTEM OFF.

Related