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

How to disable NRF52832 BLE power shutdown?

We are using NRF52832 with SDK15.0 to develop a wearable device that collects data every 10 seconds. It works fine except that NRF52832 shuts down automatically 1 hour after power is turned on. My question is: how to disable this automatic power down?

The code is quite simple, based on the sampel code project "ble_app_uart" from  Nordic, where main() is modified as follows:

void processing(void * p_context)
{
	DrawString(++m_Count);
}

int main(void)
{
	int count = 0;
	init_ble();
	init_timer(processing);
	start_timer(2000);

	for (;;) {
		idle_state_handle();
	}
}

I traced into idle_state_handle(), that has this function nrf_pwr_mgmt_run() playing the role of shutdown. 

void nrf_pwr_mgmt_run(void)
{
    PWR_MGMT_FPU_SLEEP_PREPARE();
    PWR_MGMT_SLEEP_LOCK_ACQUIRE();
    PWR_MGMT_CPU_USAGE_MONITOR_SECTION_ENTER();
    PWR_MGMT_DEBUG_PIN_SET();

    // Wait for an event.
#ifdef SOFTDEVICE_PRESENT
    if (nrf_sdh_is_enabled())
    {
        ret_code_t ret_code = sd_app_evt_wait();
        ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED));
        UNUSED_VARIABLE(ret_code);
    }
    else
#endif // SOFTDEVICE_PRESENT
    {
        // Wait for an event.
        __WFE();
        // Clear the internal event register.
        __SEV();
        __WFE();
    }

    PWR_MGMT_DEBUG_PIN_CLEAR();
    PWR_MGMT_CPU_USAGE_MONITOR_SECTION_EXIT();
    PWR_MGMT_SLEEP_LOCK_RELEASE();
}


Interestingly, the shutdown will not occur if PWR_MGMT_FPU_SLEEP_PREPARE() is commented out. I assume that some kind counter is in this function, and clear of the counter will also prevent CPU fron shutdown. Unfortunately, this function can not be traced.

What to do to disable the shutdown thing? Many Thanks

Best regards, Dimtai

Parents
  • Hi Einar, thanks for the answer.

    I don't know what happens with "shutdown", as I couldn't trace into the code. The CPU's current consumption goes from about 0.3mA down to about 0.3uA when it's down and ble is also gone, but it can be awaken by a button press. I assume it's a system OFF mode.

    There is a constant periodic call of idle_state_handle() at precisely 1 sec interval in main() for loop. If PWR_MGMT_FPU_SLEEP_PREPARE() is commented out, the ticks go a lot faster, with irregular intervals much less than 0.1 sec. I don't know where this is from. SOFTDEVICE_PRESENT is present in this case, but it appears that the 1 sec interval is not from sd_app_evt_wait().

    There is no timer started in the case, although app_timer_init() is surely called in init_ble(), otherwise BLE will not work. The actual init_ble() is as follows.

    void init_ble(void)
    {
    	bool erase_bonds = 1;
    	// Initialize.
    	app_timer_init();
    	log_init();
    	buttons_leds_init(&erase_bonds);
    	power_management_init();
    
    	//BLE related initialization
    	ble_stack_init();
    	gap_params_init();
    	gatt_init();
    	services_init();
    	advertising_init();
    	conn_params_init();
    	advertising_start(erase_bonds, BLE_ADV_MODE_FAST);
    }

    The shutdown happens accurately when 3600 counts are achieved calling idle_state_handle(), and so I guess there should be a clock ticking somewhere. My question is: how to find this counter and how to clear it? And by doing so, can I disable NRF52832 power shutdown momentarily?

    Thanks again. Best regards, dimtai.

  • Hi,

    There should not be any such counter in the SDK, so I am curious about seeing your code. Can you upload your complete project to this thread?

    Br,

    Einar

Reply Children
Related