6. Deep Sleep configuration
To configure DA1453x or DA1458x device to deep sleep mode, follow the steps mentioned below:
Open the proximity reporter project from the following address:
...projects/target_apps/ble_examples/prox_reporter/Keil_5
Open the file user_proxr.h which is under the user_app folder.
Define CFG_APP_GOTO_DEEP_SLEEP to select the sleep mode that the device enters after completion of advertisement.
#define CFG_APP_GOTO_DEEP_SLEEP
Select the trigger mechanism to wake-up from deep sleep mode by doing the following,
#if defined(CFG_APP_GOTO_DEEP_SLEEP)
/****************************************************************************************
* 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. *
****************************************************************************************/
#undef CFG_DEEP_SLEEP_WAKEUP_POR
#define CFG_DEEP_SLEEP_WAKEUP_GPIO
Note
DA1458x can wake up from deep sleep from POR pin or GPIO only.
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_RAM1 PD_SYS_DOWN_RAM_OFF
#define CFG_DEEP_SLEEP_RAM2 PD_SYS_DOWN_RAM_OFF
#define CFG_DEEP_SLEEP_RAM3 PD_SYS_DOWN_RAM_OFF
#define CFG_DEEP_SLEEP_PAD_LATCH_EN false
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 ,
#if defined (CFG_DEEP_SLEEP_WAKEUP_GPIO)
wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // Select pin
WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // Polarity low
1, // 1 event
0); // debouncing time = 0
#endif
In the user_periph_setup.h, configure the
GPIO_BUTTON_PORT
andGPIO_BUTTON_PIN
, like so where we have configuredP0_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
#else
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.
#define CFG_DEEP_SLEEP_WAKEUP_POR
To wake up using RTC (Real Time Clock) timer (ONLY for DA1453x) , define CFG_DEEP_SLEEP_WAKEUP_RTC and undefine the rest of the wake-up mechanism.
#if defined (__DA14531__)
#define CFG_DEEP_SLEEP_WAKEUP_RTC
#undef CFG_DEEP_SLEEP_WAKEUP_TIMER1
#endif
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 static void configure_rtc_wakeup(void)
in user_proxr.c as shown below,
alarm_time.sec += 10;
To wake up using Timer1 (ONLY for DA1453x), define
CFG_DEEP_SLEEP_WAKEUP_TIMER1
and undefine the rest of the wake-up mechanism.
#if defined (__DA14531__)
#undef CFG_DEEP_SLEEP_WAKEUP_RTC
#define CFG_DEEP_SLEEP_WAKEUP_TIMER1
#endif
Save and compile (F7) the project
Open our SmartSnippets toolbox , click on Power Profiler and observe the BLE events and Deep sleep.
If you are using the DA1453x Tiny module, make sure to power down the flash before entering deep sleep by
calling spi_flash_power_down()
in functionapp_advertise_complete
in user_proxr.c, like:
spi_flash_power_down();
// Put system into deep sleep
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:
Open the file user_config.h which is under the user_config folder.
Change the default handlers configuration to advertise the device with a timeout, by configuring
.adv_scenario
toDEF_ADV_WITH_TIMEOUT
and changing the timeout value to 3s , as shown below:
/*
****************************************************************************************
*
* 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:
// - DEF_ADV_FOREVER
// - DEF_ADV_WITH_TIMEOUT
.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:
// - DEF_SEC_REQ_NEVER
// - DEF_SEC_REQ_ON_CONNECT
.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.
Save and Compile the project
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.
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 15 Deep sleep power measurement
DA1453x DEVKT-P
On DA1453x DEVKT-P You can use also the same configuration or using the PMM2.
To change to Boost mode, put the jumper on J4[1-2] on the motherboard, as shown in sleep mode overview chapter.
Repeat the steps from 1 to 6
For further information please refer to DA14531 DEVKT-P or DA1453x DEVKT-P.