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

wake up from system off

Hello

I have found 2 strange behavoir when I want to wake up nrf from system off state:

1/ when I use pin 15, this does not work at all, but with pin 6 it does. Why?

2/ if i use gpiote to program the gpio pin for wake up this doesn't work. I have to program the pin with nrf_gpio_xxx interface. Why this does not work with GPIOTE ?

Thanks for your answer

Mikael

Parents
  • Hi,

    Are you using the DK or a custom board? And how did you configure it to wake-up before you went to sleep? Could share your code?

    regards

    Jared

  • Hi Jared,

    I use a custom board. we use as well soft device.

    I read on other post that "The only peripherals that are partially kept active in SYSTEM OFF are GPIO, LPCOMP and NFC"

    So I deduced that GPIOTE is completely off.

    Let me know if misunderstand something.

    before I went to sleep I did

    err_code = nrfx_gpiote_init();

        APP_ERROR_CHECK(err_code);

     

      nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);

      in_config.pull = NRF_GPIO_PIN_PULLDOWN;

     

      // configure wakeup pin

      err_code = nrfx_gpiote_in_init( GPIO_WAKEUP_PIN, &in_config, wakeup_event_handler);

      APP_ERROR_CHECK(err_code);

     

      nrfx_gpiote_in_event_enable( GPIO_WAKEUP_PIN, true);

      // switch OFF both RAM banks when in System OFF mode

      NRF_POWER->RAMON |= (POWER_RAMON_OFFRAM0_RAM0Off << POWER_RAMON_OFFRAM0_Pos) |

                          (POWER_RAMON_OFFRAM1_RAM1Off << POWER_RAMON_OFFRAM1_Pos);

    but does not work

    Now I use

      // configure wakeup pin
      nrf_gpio_cfg_input( GPIO_WAKEUP_PIN, NRF_GPIO_PIN_PULLDOWN );
      nrf_gpio_cfg_sense_input( GPIO_WAKEUP_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH );

      NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
      NVIC_EnableIRQ(GPIOTE_IRQn);

    and its fine.

    but something strange even. If the gpio goes from 0 to 1 and stay to 1 this does not work. the signal shall do 0-1-0 to work.

    Regards

    Mikael

  •  Hi,

    You're assumption is correct.

    You don't need to configure the pin as input before you call the nrf_gpio_cfg_input as it will do everything itself. 

    Here is a quick sample that shows you how to configure it on the DK:

    #include <stdbool.h>
    #include <stdint.h>
    #include "nrf_delay.h"
    #include "boards.h"
    
    #define PIN_GPIO_WAKEUP 3
    
    
    /**
     * @brief Function for application main entry.
     */
    int main(void)
    {
        /* Configure board. */
        bsp_board_init(BSP_INIT_LEDS);
    
    
        for (int i = 0; i < LEDS_NUMBER; i++)
        {
            bsp_board_led_invert(i);
            nrf_delay_ms(500);
        }
    
        nrf_gpio_cfg_sense_input(PIN_GPIO_WAKEUP, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
        bsp_board_leds_off();
    
        NRF_POWER->SYSTEMOFF = 0x1;
        (void) NRF_POWER->SYSTEMOFF;
        while (true);   
    }

  • Ok thank you for the answer.

    have you got an idea of question 1?

    1/ when I use pin 15, this does not work at all, but with pin 6 it does. Why?

    thanks

  • Hi,

    Are you using a custom board or a Development kit? If you're using the development kit and pin 15 then you have to observe that pin 15 is connected to Button 3. The pin is therefore connected to a button switch, that connects the pin to gnd when you press the button. You therefore have to do it like this:

    #include <stdbool.h>
    #include <stdint.h>
    #include "nrf_delay.h"
    #include "boards.h"
    
    #define PIN_GPIO_WAKEUP 3
    
    
    /**
     * @brief Function for application main entry.
     */
    int main(void)
    {
        /* Configure board. */
        bsp_board_init(BSP_INIT_LEDS);
    
    
        for (int i = 0; i < LEDS_NUMBER; i++)
        {
            bsp_board_led_invert(i);
            nrf_delay_ms(500);
        }
        
        //Note the difference in the PULLUP and the Sense requirment being changed to NRF_GPIO_PIN_SENSE_LOW 
        nrf_gpio_cfg_sense_input(BUTTON_3, NRF_GPIO_PIN_PULLUP,NRF_GPIO_PIN_SENSE_LOW);
        bsp_board_leds_off();
    
        NRF_POWER->SYSTEMOFF = 0x1;
        (void) NRF_POWER->SYSTEMOFF;
        while (true);   
    }

Reply
  • Hi,

    Are you using a custom board or a Development kit? If you're using the development kit and pin 15 then you have to observe that pin 15 is connected to Button 3. The pin is therefore connected to a button switch, that connects the pin to gnd when you press the button. You therefore have to do it like this:

    #include <stdbool.h>
    #include <stdint.h>
    #include "nrf_delay.h"
    #include "boards.h"
    
    #define PIN_GPIO_WAKEUP 3
    
    
    /**
     * @brief Function for application main entry.
     */
    int main(void)
    {
        /* Configure board. */
        bsp_board_init(BSP_INIT_LEDS);
    
    
        for (int i = 0; i < LEDS_NUMBER; i++)
        {
            bsp_board_led_invert(i);
            nrf_delay_ms(500);
        }
        
        //Note the difference in the PULLUP and the Sense requirment being changed to NRF_GPIO_PIN_SENSE_LOW 
        nrf_gpio_cfg_sense_input(BUTTON_3, NRF_GPIO_PIN_PULLUP,NRF_GPIO_PIN_SENSE_LOW);
        bsp_board_leds_off();
    
        NRF_POWER->SYSTEMOFF = 0x1;
        (void) NRF_POWER->SYSTEMOFF;
        while (true);   
    }

Children
No Data
Related