⚠️
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.
5 posts / 0 new
Last post
boydy1989
Offline
Last seen:1 year 9 months ago
加入:2017-10-18 16:11
Deep Sleep question

Hello

I have a question around the Deep Sleep implementation on the DA14585/6.

The SDK contains the following function:

static void put_system_into_deep_sleep(void)
{
#if defined (CFG_EXT_INT_WAKEUP_DEEP_SLEEP) && !defined (CFG_POR_WAKEUP_DEEP_SLEEP)
// configure button for wake-up interrupt
app_button_enable();
GPIO_SetInactive(GPIO_LED_PORT, GPIO_LED_PIN);
// set deep sleep - external interrupt wake up
arch_set_deep_sleep(true);

#elif defined (CFG_POR_WAKEUP_DEEP_SLEEP) && !defined (CFG_EXT_INT_WAKEUP_DEEP_SLEEP)
// configure button for POR
GPIO_EnablePorPin(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, GPIO_POR_PIN_POLARITY_LOW, GPIO_GetPorTime());

// set deep sleep - POR wake up

arch_set_deep_sleep(false);

#else
// do nothing.
// The system will eventually enter the selected Extended sleep state.
// A button press will wake up the system if the respective GPIO is configured as a wake up interrupt.
#endif
}

but the documentation states that the device will always go through a full boot up when resuming from deep sleep. If this is correct, what does the #if compiler directive change? Does the CFG_EXT_INT_WAKEUP_DEEP_SLEEP switch cause different behavior?

On the same subject, is it possible to debug deep sleep wakeups at all without burning an OTP - I am trying to test my code before committing to a test device, and although the device wakes up OK it doesn't resume advertising as I am expecting.

I have based this project on the ble_app_peripheral, with extracts also used from ble_app_sleepmode and prox_reporter.

Thanks!

Device:
PM_Dialog
Offline
Last seen:16 hours 23 min ago
Staff
加入:2018-02-08 11:03
Hi boydy1989,

Hi boydy1989,

The #if compiler directive checks if the CFG_EXT_INT_WAKEUP_DEEP_SLEEP and if the CFG_POR_WAKEUP_DEEP_SLEEP is not defined. If that condition is true, then the device will wake up from an external interrupt, else it will wake up from a Power-on-Reset (POR) button. By defining these two hashtag define, you select how the chip will wake up from the deep sleep, so the definition CFG_EXT_INT_WAKEUP_DEEP_SLEEP will cause different behavior in your application as mentioned. In order to wake up from the deep sleep, your code must be in the OTP, in order to be copied into the SysRAM, and after that will be executed. According to DA14585/586 SDK 6 Software Platform Reference (UM-B-079) user manual document, the SysRAM blocks off, nothing is retained, so you will not be able to attach the debugger. However, there is an option in the SDK to run your code in development mode that emulate the deep sleep and the SysRAM is not closed. In order to run your code in development mode, please define the CFG_DEVELOPMENT_DEBUG in the da1458x_config_basic.h header file.

Thanks, PM_Dialog

boydy1989
Offline
Last seen:1 year 9 months ago
加入:2017-10-18 16:11
谢谢你的

谢谢你的clarification!

boydy1989
Offline
Last seen:1 year 9 months ago
加入:2017-10-18 16:11
I have just attempted this

I have just attempted this CFG_DEBUG switch, and I am still having a problem - the device appears to reset OK from the external interrupt, but it doesn't begin advertising as expected.

My code for these, copied mainly from the examples.

/**
****************************************************************************************
* @brief Handles APP_WAKEUP_MSG sent when device exits deep sleep. Triggered by button press.
* @return void
****************************************************************************************
*/
static void app_wakeup_cb(void)
{
if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
{
periph_init();
}

if (arch_ble_ext_wakeup_get())
{
arch_set_sleep_mode(app_default_sleep_mode);
arch_ble_force_wakeup();
arch_ble_ext_wakeup_off();
app_easy_wakeup();
}
// If state is not idle, ignore the message
if (ke_state_get(TASK_APP) == APP_CONNECTABLE)
{

user_app_adv_start();

}
}

/**
****************************************************************************************
* @brief Button press callback function. Registered in WKUPCT driver.
* @return void
****************************************************************************************
*/
static void app_button_press_cb(void)
{

if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
{
periph_init();
app_wakeup_cb();
}

if (arch_ble_ext_wakeup_get())
{
arch_set_sleep_mode(app_default_sleep_mode);
arch_ble_force_wakeup();
arch_ble_ext_wakeup_off();
app_easy_wakeup();
}

}

void app_button_enable(void)
{
app_easy_wakeup_set(app_wakeup_cb);
wkupct_register_callback(app_button_press_cb);

wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
1, // 1 event
0); // debouncing time = 0
}

Can you advise please?

Thanks again!

PM_Dialog
Offline
Last seen:16 hours 23 min ago
Staff
加入:2018-02-08 11:03
Hi Jun-ichi Tobe,

Hi Jun-ichi Tobe,

当DA14585配置处于深度睡眠模式only the wakeup controller or the POR circuit remains switched on depending on the option selected. As mentioned before, the SysRAM blocks off, nothing is retained, so you will not be able to attach the debugger. If you want to wake up from the deep sleep, your code must be in the OTP, in order to be copied into the SysRAM, and after that will be executed. So, you are not able to wake up your device from the deep sleep mode. In DA14585 SDK, there is an option to configure your device in extended sleep mode with OTP copy. In this mode there is an OTP copy if the device boots from OTP and only 32kB (block 4) of the SysRAM remains switched on. So, in order to wake up without booting from OTP, I suggest you configure your device as extended sleep mode or as extended sleep mode with OTP copy. Otherwise, in deep sleep mode, the sysRAM is switched off and you will not be able to wake up. A correction in my previous post is that with the CFG_DEVELOPMENT_DEBUG and with deep sleep configuration, the sysRAM is closed, so you will not able to wake up.

Thanks, PM_Dialog