⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
Gerbers
Offline
Last seen:1 year 9 months ago
Joined:2017-10-30 22:11
Implementing Deep Sleep

Dear Dialog Staff:
For my project, I have modified the ble_app_peripheral in SDK 5.0.4. I’ve tested my project using the DA14580 Basic dev board and the SPI Flash. It works fine. I now need to add sleep mode code. I would like to add the sleep mode functionality from the ble_app_sleepmode project into my project. Initial attempts have failed.

When testing the ble_app_sleepmode, deep sleep is activated after 10s and advertising stops. In my project, advertising continues so I assume deep sleep was never activated.
Here is the code that I duplicated from the ble_app_sleepmode project:

*********************************************************************************
const static sleep_state_t app_default_sleep_mode = ARCH_DEEP_SLEEP_ON;
*********************************************************************
void user_app_adv_start(void)
{
/*code*/

arch_set_deep_sleep(); // Set deep sleep during advertising

/*code*/
}
**************************************************
#undef CFG_MEM_MAP_EXT_SLEEP
#define CFG_MEM_MAP_DEEP_SLEEP
*****************************************************************
* Scatterfile: Memory maps
*/
#if defined(CFG_MEM_MAP_EXT_SLEEP) || !defined(CFG_MEM_MAP_DEEP_SLEEP)
#define REINIT_DESCRIPT_BUF 0 //0: keep in RetRAM, 1: re-init is required (set to 0 when Extended Sleep is used)
#define USE_MEMORY_MAP EXT_SLEEP_SETUP
#else
#define REINIT_DESCRIPT_BUF 0 //0: keep in RetRAM, 1: re-init is required (set to 0 when Extended Sleep is used)
#define USE_MEMORY_MAP DEEP_SLEEP_SETUP
#定义DB_HEAP_SZ 1024
#define ENV_HEAP_SZ 328
#define MSG_HEAP_SZ 1312
#define NON_RET_HEAP_SZ 1024
#endif

Regarding the wake up button, I have not added this code yet. I plan to add an external button which interfaces the DA14580 basic board. Perhaps not having this button code is the issue?
我阅读所有的the sleep mode related documents I could find before reaching out to Dialog. I appreciate any support you can offer.

Device:
MT_dialog
Offline
Last seen:2 months 3 days ago
Staff
Joined:2015-06-08 11:34
Hi Gerbers,

Hi Gerbers,

A few things regarding how the system works, so, when the device is operating in sleep mode it means that it will go to sleep between BLE events (BLE events are considered the advertising events, the connection events, BLE timers). The fact that your device keeps on advertising doesn't mean that it doesn't go sleep, since the device keeps on advertising it means that you have never cancelled the advertising operation (the ble_app_sleepmode sets up a kernel timer using the app_easy_timer() that will invoke in its callback the app_easy_gap_advertise_stop() and then as soon as the stack replies that the advertising has stopped it will set up the button - check the user_app_adv_undirect_complete). Since the advertising is stopped and the device has no upcomming BLE event the device will never wake up until an external interrupt (a push button) wakes the system. Let me know if this is clear.

Thanks MT_dialog

Gerbers
Offline
Last seen:1 year 9 months ago
Joined:2017-10-30 22:11
Thank you for your

Thank you for your explanation. It was very helpful. I have more questions on this topic but will post them in a new thread as requested in the reply instructions.
-Shawn

MT_dialog
Offline
Last seen:2 months 3 days ago
Staff
Joined:2015-06-08 11:34
Hi Gerbers,

Hi Gerbers,

Glad it helped.

Best Regards MT_dialog