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

nRF52832 Controlling Sleep Behavior with GPIO Pin

Hello,

I'm making an application that I want to have the following behavior:

1) 52832 starts in sleep mode

2)P0.14 pulls to LOW which brings out of sleep mode and then goes back to sleep after running application

3)P0.14 stays LOW and the 52832 stays in sleep mode

4)When P0.14 goes HIGH again 52832 comes back out of sleep mode and runs the application again

The problem I'm running into is that if P0.14 brings the 52832 out of sleep mode upon LOW that I can't keep the 52832 in sleep mode while that pin continues to stay LOW.  Is there a way to make the 52832 not come out of sleep mode after step 2 (above)?  For example:

1) 52832 starts in sleep mode

2)P0.14 pulls to LOW which brings out of sleep mode 

3) Somewhere in the application, change the logic to only wake up when P0.14 changes state/goes HIGH, and disable it from  coming out of state if LOW

4) 52832 then goes to sleep and only wakes up when P0.14 goes HIGH

5) After going HIGH and running the software configure to wake back up if P0.14 goes low

Thanks!

Parents
  • Hi,

    Which sleep mode are you using (System ON/System OFF)?

    How have you configured the GPIO for wakeup from sleep mode? It should definitely be possible to change the configuration after wakeup, to only wakeup on next transition to high. How to achieve this depends on how you have configured the GPIO in the first place, so we would need to see your code in order to help you.

    Best regards,
    Jørgen

  • I had just been using the function provided in the BLE_app example which is:

    static void sleep_mode_enter(void)
    {
        uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup buttons.
        err_code = bsp_btn_ble_sleep_mode_prepare();
        APP_ERROR_CHECK(err_code);
    
        // Go to system-off mode (this function will not return; wakeup will cause a reset).
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
    }

    So this is just putting the device in System ON mode it looks like?  

    Then to use the switch I just configured the pin as below and read its state directly.  

    //Button is P0.14
    nrf_gpio_cfg_input(Button, NRF_GPIO_PIN_PULLUP);
    

    So it looks like I need to change to put the device into System OFF mode, then make the condition to come out of System OFF mode to be when P0.14 goes HIGH as it will stay LOW until the system needs to wake up again.

    Is this the correct way to go about this?  And how do I configure to only come out of System OFF mode upon the single P0.14 HIGH condition?

Reply
  • I had just been using the function provided in the BLE_app example which is:

    static void sleep_mode_enter(void)
    {
        uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup buttons.
        err_code = bsp_btn_ble_sleep_mode_prepare();
        APP_ERROR_CHECK(err_code);
    
        // Go to system-off mode (this function will not return; wakeup will cause a reset).
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
    }

    So this is just putting the device in System ON mode it looks like?  

    Then to use the switch I just configured the pin as below and read its state directly.  

    //Button is P0.14
    nrf_gpio_cfg_input(Button, NRF_GPIO_PIN_PULLUP);
    

    So it looks like I need to change to put the device into System OFF mode, then make the condition to come out of System OFF mode to be when P0.14 goes HIGH as it will stay LOW until the system needs to wake up again.

    Is this the correct way to go about this?  And how do I configure to only come out of System OFF mode upon the single P0.14 HIGH condition?

Children
No Data
Related