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

Sleep Modes and Wakeup Through GPIO IRQ

I have attached all sleep modes of our controller that i found through forums and from your suggestions.

But my problem is No one of these sleep modes, wake-up through GPIO IRQ.

Please provide me accurate details along with accurate settings of SLEEP MODES and WAKE-UP using GPIO IRQ.

I want to sleep my system(OFF), and it's wake-up on GPIO IRQ as RESET.

(I want full system go into OFF mode BLE, timers, and all other thing will off, BUT GPIO IRQ WORKING and my system wake-up through GPIO IRQ)

But in every sleep mode our GPIO has been disable or not working properly.

Please go through my attachment and suggest me what i have do for this sleep and wake-up mode using GPIO IRQ.New Microsoft Office Word Document (3).docx

Parents
  • Hi Einar,

    Does  nrf_gpio_cfg_sense_input work with softdevice ?

    Regards,

    Rixtronix LAB

  • Hi,

    Yes, nrf_gpio_cfg_sense_input() can be used together with the SoftDevice.

  • Hi Enar,

    Does bsp_button_is_pressed() work with softdevice ?

    and will ant button initialization overwrite all the bsp init ?

    Regards,

    Rixtronix LAB

  • Hi,

    RixtronixLAB said:
    Does bsp_button_is_pressed() work with softdevice ?

    Yes.

    RixtronixLAB said:
    and will ant button initialization overwrite all the bsp init ?

    I am not entirely sure what you mean. Can you elaborate?

  • Hi Einar,

    Thanks for the reply,

    Will this function overwrite "bsp_button_is_pressed()" function ?

    static void utils_setup(void)
    {
        //ret_code_t err_code;
    	  ret_code_t err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
        //originally
        err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS ,
                            bsp_event_handler);
    	  /*
    	  err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS,   //bsp_button_event_handler at E:\nRF5_SDK_17.0.2_d674dde\components\libraries\bsp\bsp.c 24Mar22 Rixtronix LAB
                            bsp_button_event_handler);
    	  */
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_pwr_mgmt_init();
        APP_ERROR_CHECK(err_code);
    		
    	    
    	
        err_code = bsp_btn_ant_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    
        //err_code = ant_state_indicator_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  err_code = bsp_btn_ant_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		
    		err_code = bsp_btn_ant_init(m_ant_bpwr.channel_number, BPWR_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  //err_code = ant_state_indicator_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		NRF_LOG_INFO("utils_setup\r\n");
    }
    static void utils_setup(void)
    {
        //ret_code_t err_code;
    	  ret_code_t err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
        //originally
        err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS ,
                            bsp_event_handler);
    	  /*
    	  err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS,   //bsp_button_event_handler at E:\nRF5_SDK_17.0.2_d674dde\components\libraries\bsp\bsp.c 24Mar22 Rixtronix LAB
                            bsp_button_event_handler);
    	  */
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_pwr_mgmt_init();
        APP_ERROR_CHECK(err_code);
    		
    	    
    	
        err_code = bsp_btn_ant_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    
        //err_code = ant_state_indicator_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  err_code = bsp_btn_ant_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		
    		err_code = bsp_btn_ant_init(m_ant_bpwr.channel_number, BPWR_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  //err_code = ant_state_indicator_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		NRF_LOG_INFO("utils_setup\r\n");
    }
    

    I put this function,

     	// Wake up button 28Mar22 Rixtronix LAB
        nrf_gpio_cfg_sense_input(BSP_BUTTON_3, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);

    after

    log_init(); //comment out for GPS test 26 Oct 21
        utils_setup(); //comment out for GPS test 26 Oct 21
    	  
        softdevice_setup(); //comment out for GPS test 26 Oct 21

    but I can't get a proper response,

    BSP_BUTTON_3 is working well for shutdown but can not turn on

    	 void bsp_event_handler(bsp_event_t event)
    	 .
    	 .
    	 .
    	 case BSP_EVENT_KEY_2:
    					 //NRF_LOG_INFO("BSP_EVENT_KEY 2 PUSH \n");
    				   if(button2_state)
    										{
    										
    											 NRF_LOG_INFO("BSP_EVENT_KEY 2 PUSH OFF\n");
    												button2_state = STATE2_OFF;  
    										
    										}
    										else
    										{
    											  NRF_LOG_INFO("BSP_EVENT_KEY 2 PUSH ON\n");
    												button2_state = STATE2_ON;
    											
    										}

    at main :

    if(button2_state==STATE2_OFF) //check button2 ON/OFF flag
    {	
      ssd1306_Power_On();
    	nrf_delay_ms(888);		
    	nrf_pwr_mgmt_run(); //Enter System On sleep mode****Rixtronix LAB 28Mar22
    	
    }		 
    
    if(button2_state==STATE2_ON) //check button2 ON/OFF flag
    {	
      ssd1306_Power_Off();
    	nrf_delay_ms(888);	
      ssd1306_displayOff();	
    	nrf_delay_ms(888);	
    	//nrf_pwr_mgmt_run(); //Enter System On sleep mode****Rixtronix LAB 28Mar22
    	nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);//Enter System Off sleep mode****Rixtronix LAB 28Mar22
    	
    }		 
    

    Any clues ?

    Regards,

    Rixtronix LAB

Reply
  • Hi Einar,

    Thanks for the reply,

    Will this function overwrite "bsp_button_is_pressed()" function ?

    static void utils_setup(void)
    {
        //ret_code_t err_code;
    	  ret_code_t err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
        //originally
        err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS ,
                            bsp_event_handler);
    	  /*
    	  err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS,   //bsp_button_event_handler at E:\nRF5_SDK_17.0.2_d674dde\components\libraries\bsp\bsp.c 24Mar22 Rixtronix LAB
                            bsp_button_event_handler);
    	  */
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_pwr_mgmt_init();
        APP_ERROR_CHECK(err_code);
    		
    	    
    	
        err_code = bsp_btn_ant_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    
        //err_code = ant_state_indicator_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  err_code = bsp_btn_ant_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		
    		err_code = bsp_btn_ant_init(m_ant_bpwr.channel_number, BPWR_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  //err_code = ant_state_indicator_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		NRF_LOG_INFO("utils_setup\r\n");
    }
    static void utils_setup(void)
    {
        //ret_code_t err_code;
    	  ret_code_t err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
        //originally
        err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS ,
                            bsp_event_handler);
    	  /*
    	  err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS,   //bsp_button_event_handler at E:\nRF5_SDK_17.0.2_d674dde\components\libraries\bsp\bsp.c 24Mar22 Rixtronix LAB
                            bsp_button_event_handler);
    	  */
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_pwr_mgmt_init();
        APP_ERROR_CHECK(err_code);
    		
    	    
    	
        err_code = bsp_btn_ant_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    
        //err_code = ant_state_indicator_init(m_ant_hrm.channel_number, HRM_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  err_code = bsp_btn_ant_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		
    		err_code = bsp_btn_ant_init(m_ant_bpwr.channel_number, BPWR_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    	
    	  //err_code = ant_state_indicator_init(m_ant_bsc.channel_number, BSC_DISP_CHANNEL_TYPE);
        APP_ERROR_CHECK(err_code);
    		NRF_LOG_INFO("utils_setup\r\n");
    }
    

    I put this function,

     	// Wake up button 28Mar22 Rixtronix LAB
        nrf_gpio_cfg_sense_input(BSP_BUTTON_3, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);

    after

    log_init(); //comment out for GPS test 26 Oct 21
        utils_setup(); //comment out for GPS test 26 Oct 21
    	  
        softdevice_setup(); //comment out for GPS test 26 Oct 21

    but I can't get a proper response,

    BSP_BUTTON_3 is working well for shutdown but can not turn on

    	 void bsp_event_handler(bsp_event_t event)
    	 .
    	 .
    	 .
    	 case BSP_EVENT_KEY_2:
    					 //NRF_LOG_INFO("BSP_EVENT_KEY 2 PUSH \n");
    				   if(button2_state)
    										{
    										
    											 NRF_LOG_INFO("BSP_EVENT_KEY 2 PUSH OFF\n");
    												button2_state = STATE2_OFF;  
    										
    										}
    										else
    										{
    											  NRF_LOG_INFO("BSP_EVENT_KEY 2 PUSH ON\n");
    												button2_state = STATE2_ON;
    											
    										}

    at main :

    if(button2_state==STATE2_OFF) //check button2 ON/OFF flag
    {	
      ssd1306_Power_On();
    	nrf_delay_ms(888);		
    	nrf_pwr_mgmt_run(); //Enter System On sleep mode****Rixtronix LAB 28Mar22
    	
    }		 
    
    if(button2_state==STATE2_ON) //check button2 ON/OFF flag
    {	
      ssd1306_Power_Off();
    	nrf_delay_ms(888);	
      ssd1306_displayOff();	
    	nrf_delay_ms(888);	
    	//nrf_pwr_mgmt_run(); //Enter System On sleep mode****Rixtronix LAB 28Mar22
    	nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);//Enter System Off sleep mode****Rixtronix LAB 28Mar22
    	
    }		 
    

    Any clues ?

    Regards,

    Rixtronix LAB

Children
  • Hi,

    RixtronixLAB said:
    Will this function overwrite "bsp_button_is_pressed()" function ?

    The bsp_button_is_pressed() simply reads the state of a GPIO pin , in the end using nrf_gpio_pin_read(). So this cannot be "overwritten". But if you change the confguration of this pin, for instance making it an output in stead of an input, changing pull configuration or similar, then it will affect how you read it.

    There are fundamental flaws about this code snippet, though, which are not directlyrelated to the question. You are making repeated calls to bsp_btn_ant_init(), but this function is intended to be called once, and any subsequent call will overwrite the previous configuration (it updates internal static variables so there is only one channel and channel type at a time).

    PS: This is getting quite detailed and straying away from the original topic of this thread. Please make a new case for new questions in the future.

Related