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

system off mode in nrf51822

hello there , i have put my nrf51 dk in system off mode.then i am generating interrupt using button 3 to wake up it. but my nrf51dk can't wake up. can you hel p me??

my main function and interrupt handler function are as below

  int main(void)
{
    uint32_t err_code;
    bool erase_bonds;
	ret_code_t ret_code;
	    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
  ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
	advertising_start();
    conn_params_init();
			  ret_code = nrf_drv_gpiote_init();
      nrf_drv_gpiote_out_config_t led_config = GPIOTE_CONFIG_OUT_TASK_LOW;
			 
    ret_code =  nrf_drv_gpiote_out_init(LED_3, &led_config);
  err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
	
  nrf_drv_gpiote_in_config_t config =
    {
      //  .sense = NRF_GPIOTE_POLARITY_HITOLO,
			.sense =NRF_GPIOTE_POLARITY_TOGGLE, //NRF_GPIOTE_POLARITY_LOTOHI,
       .pull = NRF_GPIO_PIN_PULLUP , // NRF_GPIO_PIN_NOPULL
			// .pull = NRF_GPIO_PIN_PULLUP ,
        .is_watcher = false,
        .hi_accuracy = false
    };
        ret_code = nrf_drv_gpiote_in_init(INTERRUPT_PIN, &config, gpiote_evt_handler);
		nrf_drv_gpiote_in_event_enable(INTERRUPT_PIN,true);
		nrf_gpio_cfg_sense_input(INTERRUPT_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
			sd_power_system_off();
 

    while(true)
    { 
    }
}



void gpiote_evt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    switch(action)
    {
      case    NRF_GPIOTE_POLARITY_TOGGLE:
            if(nrf_drv_gpiote_in_is_set(INTERRUPT_PIN))
            { // sd_power_system_off();
             // nrf_drv_gpiote_out_clear(LED_3);
            }
            else							
            {  
							nrf_drv_gpiote_out_set(LED_3);
            }
            break;
        default:
            //do nothing
            break;
    }
}
Related