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,

    By shutdown, what exactly do you mean? System OFF mode?

    Are you confident that PWR_MGMT_FPU_SLEEP_PREPARE() is related? It doesn't makes sense to me when I am looking at the code. Regarding PWR_MGMT_FPU_SLEEP_PREPARE(), this will be pwr_mgmt_fpu_sleep_prepare() if you have NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED set to 1 in your projects sdk_config.h. If not, it will just be replaced with nothing by the preprocessor (no function call at all).

    Are you sure there is no timer or other event that causes your device to go into some kind of idle state?

Reply
  • Hi,

    By shutdown, what exactly do you mean? System OFF mode?

    Are you confident that PWR_MGMT_FPU_SLEEP_PREPARE() is related? It doesn't makes sense to me when I am looking at the code. Regarding PWR_MGMT_FPU_SLEEP_PREPARE(), this will be pwr_mgmt_fpu_sleep_prepare() if you have NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED set to 1 in your projects sdk_config.h. If not, it will just be replaced with nothing by the preprocessor (no function call at all).

    Are you sure there is no timer or other event that causes your device to go into some kind of idle state?

Children
Related