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

Manage power state using interrupt

void input_pin_handle(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
  // Shutdown device here
}

void gpio_init()
{
  ret_code_t err_code;

  err_code = nrf_drv_gpiote_init();
  APP_ERROR_CHECK(err_code);
  
  nrf_gpio_cfg_output(LED);
  nrf_gpio_pin_set(LED);

  nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
  in_config.pull = NRF_GPIO_PIN_PULLUP;

  err_code = nrf_drv_gpiote_in_init(BUTTON_1, &in_config, input_pin_handle);
  APP_ERROR_CHECK(err_code);

  nrf_drv_gpiote_in_event_enable(BUTTON_1, true);
}

I'm using this code to handle interrupt and power down the device. However, this code is not working the softdevice.

I just want to power on and power off using an interrupt signal.

Parents
  • Yes it is.

    The interrupt did work, but i had to comment out the following code in ble_uart example 

    static void buttons_leds_init(bool * p_erase_bonds)
    {
        bsp_event_t startup_event;
    
        //uint32_t err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
       // APP_ERROR_CHECK(err_code);
    
        //err_code = bsp_btn_ble_init(NULL, &startup_event);
      //  APP_ERROR_CHECK(err_code);
    
        *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
    }


    The buttons_leds_init(&erase_bonds); was being called from the main function.

    I'm try to put system to sleep. I tried following commands - sd_app_evt_wait(), or nrf_pwr_mgmt_run()

    and trying to wake up the system using interrupt. But as I use any of this function it am being thrown to     4B01        ldr r3

  • Yes, the code in buttons_leds_init() was likely overriding your pin configuration.

    "4B01        ldr r3" is just a line of assembly code and it could be anywhere in your program. Either way,  please confirm that GPIOTE_CONFIG_IRQ_PRIORITY is set to '6' in your sdk_config header. Calliong sd_app_evt_wait() from a high priority interrupt will lead to a fault exception.

Reply
  • Yes, the code in buttons_leds_init() was likely overriding your pin configuration.

    "4B01        ldr r3" is just a line of assembly code and it could be anywhere in your program. Either way,  please confirm that GPIOTE_CONFIG_IRQ_PRIORITY is set to '6' in your sdk_config header. Calliong sd_app_evt_wait() from a high priority interrupt will lead to a fault exception.

Children
No Data
Related