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

Can uart peripherial activity wakeup device from sleep ?

Dear Sir,

I am new in nRF51 and used the ble_app_uart example in our application (nRF51), need power saving function but not necessary power off.

The sample code will power off nRF51 as below, and only can wakeup by pressing button.

static void sleep_mode_enter(void)
{
	uint32_t err_code;
	err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
	
	// Prepare wakeup buttons.
	err_code = bsp_btn_ble_sleep_mode_prepare();
	APP_ERROR_CHECK(err_code);
		
	// Go to system-off mode (this function will not return; wakeup will cause a reset).
	err_code = sd_power_system_off();
	APP_ERROR_CHECK(err_code);
}
  1. How to change code so that the device will enter sleep mode (not necessary power off )when there is no UART /BLE activity after 30 seconds even in the connected state and can wakeup when UART exists activity even in the disconnected state ? (received data from UART port)

  2. How to handle the input data of UART that wakeup device ? must skip ? or data will keep in buffer without lost or fragment .

  3. How to let host APP to know device been wakeup/enter sleep during connect state ?

  4. Or other method which can wakeup device from UART activity ?

Can provide example will much helpful.

Thanks in advance.

    1. don't have any of that power off code, just use sd_app_evt_wait() which will sleep the chip whenever there's nothing for the CPU to do.

    2. If you're in power-off mode then you will lose any UART data, but if you are just sleeping (sd_app_evt_wait()) then the UART will clock in data and generate an interrupt which will bring you out of sleep mode, as long as you are using interrupts for it.

    3. The device only sleeps when you run code which sleep it, ie the power off code you show, or sd_app_evt_wait(), so you already know when you're sleeping.

    4. Don't really understand what you're asking here.

Related