6. Deep Sleep configuration

To configure DA14531 or DA14585/586 device to deep sleep mode, follow the steps mentioned below.

  1. Open the proximity reporter project from: …projects/target_apps/ble_examples/prox_reporter/Keil_5

  2. Open the file user_proxr.h which is under the user_app folder.

  3. Define CFG_APP_GOTO_DEEP_SLEEP to select the sleep mode that the device enters after completion of advertisement.

  1. Select the trigger mechanism to wake-up from deep sleep mode by doing the following,

* Deep Sleep mode and Wake-up from Deep Sleep Configuration                             *
* Selects the trigger mechanism to wake up from deep sleep.                             *
*                                                                                       *
* - CFG_DEEP_SLEEP_WAKEUP_POR       - Wake up from POR pin                              *
*                                                                                       *
* - CFG_DEEP_SLEEP_WAKEUP_GPIO      - Wake up from WakeUp Controller                    *
*                                                                                       *
* - CFG_DEEP_SLEEP_WAKEUP_RTC       - Wake up from RTC Timer (only in DA14531)          *
*                                                                                       *
* - CFG_DEEP_SLEEP_WAKEUP_TIMER1    - Wake up from Timer1 (only in DA14531)             *
*                                                                                       *
* NOTE:                                                                                 *
* A hardware reset or power cycle will always wake up the system from deep sleep.       *



DA14585/586 can wake up from deep sleep from POR pin or GPIO only.

  1. In the same file, configure the retention RAM memory to be retained. To power down any RAM block use PD_SYS_DOWN_RAM_OFF and PD_SYS_DOWN_RAM_ON to retain. When disabling all the RAM blocks, the code should be in Flash or OTP. Disabling RAM blocks will lower the sleep current however it will increase the energy needed to wake-up.

* Deep sleep mode configuration                                                        *
#define CFG_DEEP_SLEEP_PAD_LATCH_EN    false
  1. In the file user_proxr.c by selecting CFG_DEEP_SLEEP_WAKEUP_GPIO, select the GPIO port_pin to wake the device from deep sleep, by doing this in file ,

 wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // Select pin
                   1, // 1 event
                   0); // debouncing time = 0
  1. In the user_periph_setup.h, configure the GPIO_BUTTON_PORT and GPIO_BUTTON_PIN, like so where we have configured P0_5 to wake up the device from deep sleep,

/* Button configuration                                                                 */
#if defined (__DA14531__)
    #define GPIO_BUTTON_PORT        GPIO_PORT_0
    #define GPIO_BUTTON_PIN         GPIO_PIN_5
  1. To wake up using Power on Reset (POR), define CFG_DEEP_SLEEP_WAKEUP_POR and undefine the rest of the wake-up mechanism. Use the SW1/Reset button on the motherboard to wake up the device.

  1. To wake up using RTC (Real Time Clock) timer (ONLY for DA14531) , define CFG_DEEP_SLEEP_WAKEUP_RTC and undefine the rest of the wake-up mechanism.

#if defined (__DA14531__)

By defining this, the RTC is configured to generate an interrupt after 10 seconds. This would wake up the device from deep sleep mode. The time to interrupt can be modified by changing the alarm_time.sec in function configure_rtc_wakeup in user_proxr.c as shown below,

alarm_time.sec += 10;
  1. To wake up using Timer1 (ONLY for DA14531), define CFG_DEEP_SLEEP_WAKEUP_TIMER1 and undefine the rest of the wake-up mechanism.

#if defined (__DA14531__)
  1. Save and compile (F7) the project

  2. Open our SmartSnippets toolbox and click on Power Profiler (available from our portal Dialog Semiconductor website.) and observe the BLE events and Deep sleep.

  1. If you are using the DA14531 module, make sure to power down the flash before entering deep sleep by calling spi_flash_power_down() in function app_advertise_complete in user_proxr.c, like so,


// Put system into deep sleep


6.1. Measuring the deep sleep current

In order to measure the deep sleep current over a digital multimeter, increase the advertising interval in the proximity reporter project under user_config.h. Follow the steps mentioned below:

  1. Open the file user_config.h which is under the user_config folder.

2. Change the default handlers configuration to advertise the device with a timeout, by configuring .adv_scenario to DEF_ADV_WITH_TIMEOUT and changing the timeout value to 3s for example, .advertise_period = MS_TO_TIMERUNITS(18000), as shown below, .. code:

 * Default handlers configuration (applies only for @app_default_handlers.c)
static const struct default_handlers_configuration  user_default_hnd_conf = {
    // Configure the advertise operation used by the default handlers
    // Possible values:
    .adv_scenario = DEF_ADV_FOREVER, //advertising forever

    // Configure the advertise period in case of DEF_ADV_WITH_TIMEOUT.
    // It is measured in timer units. Use MS_TO_TIMERUNITS macro to convert
    // from milliseconds (ms) to timer units.
    .advertise_period = MS_TO_TIMERUNITS(3000), //this is for 3s

    // Configure the security start operation of the default handlers
    // if the security is enabled (CFG_APP_SECURITY)
    // Possible values:
    .security_request_scenario = DEF_SEC_REQ_NEVER

This will configure the advertising period as 3s after which the device will enter the deep sleep mode. The device can wake-up from deep sleep mode by programming the trigger mechanism for wake-up as mentioned in the previous section.

  1. Save and Compile the project

  2. Follow the steps here in chapter 12 OTP Programmer or chapter 13 SPI Flash programmer to program the device either in Flash or OTP, and then boot from there.

  1. Use a digital multimeter, connect the positive of multimeter to J9[4] and the negative to J9[3] of the motherboard, as shown in the figure below,


Figure 12 Deep sleep power measurement

  1. Observe the deep sleep current value displayed in the meter. The typical numbers are mentioned below where the IBAT_LOW values are for the Boost mode and the IBAT_HIGH values are for Buck mode.


Figure 13 Deep sleep power numbers (DA14531) in buck and boost mode


Figure 14 Deep sleep power numbers (DA14585) in buck and boost mode

  1. To change to Boost mode, put the jumper on J4[1-2] on the motherboard, as shown in sleep mode overview chapter.

  2. Repeat the steps from 1 to 6