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

Unwanted reset

Hi, I'm working on a firmware that is used in a nrf51822. I discovered an unwanted behavior of my system. When the system is in power_manage mode, it can wake up in two different ways:

  • pressing a button
  • waiting 10 minutes

After pressing the button or having waited 10 minutes, the system wakes up and a 3 minutes timer starts to count from 180 seconds to 0. After reaching the 0 second, the system enters power manage mode again. When the system wakes up after having waited 10 minutes, the 3 minutes timer has no problem to reach the second 0. On the contrary, after pressing the button, the 3 minutes timer has problems to reach 0 second because there's an unwanted reset after a few seconds. Anyone can give me an explanation? Thanks!

Parents
  • FormerMember
    0 FormerMember

    The first step would be to check the reset reason register (RESETREAS) after the reset. Chapter 12.1.11 in the nRF51 Series Reference Manual explains the various reset sources.

  • I discovered which code line is generating the reset. Before entering power manage mode this code is executed

    void pre_power_manage_settings(void)
    {
    	//Timers stop
    //	system_timer_stop(); 
    	one_sec_timer_stop();
    	button_idle_timer_stop();
    	//buzzer_timer_stop();
    	//rele_timer_stop();
    	//led_repetition_timer_stop();
    	//led_timer_stop();
    	//wdt_refresh_timer_stop();
    	three_min_timer_start();
    
    	//Stop advertising
    	beacon_advertising_stop();
    	
    	
    }
    

    After having waited 10 minutes the system wakes up and this code is executed

    void post_power_manage_settings(void) 
    {
    	//Timers stop
    //	system_timer_stop(); 
    	one_sec_timer_start();
    	button_idle_timer_start();	
    	//Stop advertising
    	beacon_advertising_start();		
    }
    
    void beacon_advertising_start(void)
    {
    
    	uint32_t err_code;
    	ble_gap_addr_t ble_gap_addr;
    
    	err_code = sd_ble_gap_address_get(&ble_gap_addr);
    	
    
    	err_code = sd_ble_gap_adv_start(&m_adv_params);
    	if (err_code == NRF_SUCCESS)
    			advertising_start = true;
    
    	APP_ERROR_CHECK(err_code);
    }
        void beacon_advertising_stop(void)
    {
    	uint32_t err_code;
    	err_code = sd_ble_gap_adv_stop();
    	if (err_code == NRF_SUCCESS)
    			advertising_start = false;
    	APP_ERROR_CHECK(err_code);
    }
    

    In this case the system doesn't reset and advertising starts and timers reload with no problem. The same code is executed after pressing the button but in this particular case the system restarts. In order to avoid reset after pressing button, I should comment the code line beacon_advertising_start(); How can I start advertising again without generating a reset after pressing the button?

Reply
  • I discovered which code line is generating the reset. Before entering power manage mode this code is executed

    void pre_power_manage_settings(void)
    {
    	//Timers stop
    //	system_timer_stop(); 
    	one_sec_timer_stop();
    	button_idle_timer_stop();
    	//buzzer_timer_stop();
    	//rele_timer_stop();
    	//led_repetition_timer_stop();
    	//led_timer_stop();
    	//wdt_refresh_timer_stop();
    	three_min_timer_start();
    
    	//Stop advertising
    	beacon_advertising_stop();
    	
    	
    }
    

    After having waited 10 minutes the system wakes up and this code is executed

    void post_power_manage_settings(void) 
    {
    	//Timers stop
    //	system_timer_stop(); 
    	one_sec_timer_start();
    	button_idle_timer_start();	
    	//Stop advertising
    	beacon_advertising_start();		
    }
    
    void beacon_advertising_start(void)
    {
    
    	uint32_t err_code;
    	ble_gap_addr_t ble_gap_addr;
    
    	err_code = sd_ble_gap_address_get(&ble_gap_addr);
    	
    
    	err_code = sd_ble_gap_adv_start(&m_adv_params);
    	if (err_code == NRF_SUCCESS)
    			advertising_start = true;
    
    	APP_ERROR_CHECK(err_code);
    }
        void beacon_advertising_stop(void)
    {
    	uint32_t err_code;
    	err_code = sd_ble_gap_adv_stop();
    	if (err_code == NRF_SUCCESS)
    			advertising_start = false;
    	APP_ERROR_CHECK(err_code);
    }
    

    In this case the system doesn't reset and advertising starts and timers reload with no problem. The same code is executed after pressing the button but in this particular case the system restarts. In order to avoid reset after pressing button, I should comment the code line beacon_advertising_start(); How can I start advertising again without generating a reset after pressing the button?

Children
No Data
Related