How to program for deep sleep with BLE timer waking up

12 posts / 0 new
Last post
xuguizhong
Offline
Last seen: 2 days 6 hours ago
Joined: 2017-06-30 02:46
How to program for deep sleep with BLE timer waking up

Base on SDK 5.0.3, For making DA14580 into extend sleep with BLE timer waking up, it is no problem for me now.
But I have to make DA14580 into deep sleep with BLE timer waking up. Of course firmware is burned into OTP.

Base on project of extend sleep with BLE timer waking up, I have changed it to deep sleep followed the document "Training_04_sleep_modes_current_measurement_v1.0".
Then burn it into OTP. I find that DA14580 can`t wake up from deep sleep after BLE timer.

Could you give me a DEMO for deep sleep with BLE timer waking up ? (not deep sleep with key button waking up )

Thank you

Device: 
SDK: 
MT_dialog
Online
Last seen: 51 sec ago
Staff
Joined: 2015-06-08 11:34
Hi xuguizhong,

Hi xuguizhong,

Using the ble_app_sleep mode please check the below changed in order to operate under deep sleep mode and wake up via timer:

  • In the user_app_adv_undirect_complete function replace the interrupt initialization with the timer set up.
    • app_sleep_timer_used = app_easy_timer(1000, user_app_adv_start);
  • The timer should be in a retained memory setion, like below:
    • timer_hnd app_sleep_timer_used                __attribute__((section("retention_mem_area0"),zero_init)); // @RETENTION MEMORY
  • undefine the CFG_DEVELOPMENT_DEBUG in order for the 580 to switch of the sysram when in deep sleep.
  • Burn your application in the OTP.
  • Burn the OTP Header with the Application Flags set to "Yes"

After the above you should be good to go.

Thanks MT_dialog 

xuguizhong
Offline
Last seen: 2 days 6 hours ago
Joined: 2017-06-30 02:46
Hi MT_dialog

Hi MT_dialog

Thanks for your feedback.

My software is base on project ble_app_barebone of SDK 5.0.3, using RCX.
I find it has created a timer in "user_app_adv_start" function.
and this timer has been defined in RETENTION MEMORY.
it is OK, right?

My problem:
In my exiting software, it can go into deep sleep(the current can show 800nA in Mutimeter).
And it also can wake up after BLE timer (say, 1 second) (monitor current by oscilloscope).
But, after wake up it can`t success to keep running. no advertisement, no sleep again.
keep a higher current, say, 600 uA in Mutimeter.
Of course, if everything confirmed, I will burn one more to testing.
could you confirm if I have to transplant my software to SDK 5.0.4 from 5.0.3?

void user_app_adv_start(void)
{
// Schedule the next advertising data update
app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);
......
}
void user_app_adv_undirect_complete(uint8_t status)
{
// If advertising was canceled then update advertising data and start advertising again
if (status == GAP_ERR_CANCELED)
{
user_app_adv_start();
}
}

MT_dialog
Online
Last seen: 51 sec ago
Staff
Joined: 2015-06-08 11:34
Hi xuguizhong,

Hi xuguizhong,

If the device succesfully enters sleep mode for one time (you see about 800nA in multimeter) and then you see that in the next wake up the power consumption is about 600uA that means that the device resets, so i suppose that the 580 enters either an NMI_Handler or a Hardfault Handler. I dont think that this is something related with the SDK that you are using, you will have to check where the device ends up and what causes that reset (check if you can replicate that under development mode with deep sleep, you wont see the desired power consumption since the sysram stays on but if you can replicate that under development mode you can track what causes the issue more easy). From the code that you ve pasted i dont see anything wrong although i am not able to see where the device goes in permanent sleep, the adv_data_update_timer_cb() will cancel the advertising and the user_app_adv_undirect_complete() that will be triggered immidiatelly after that it will restart the advertising.

Thanks MT_dialog 

xuguizhong
Offline
Last seen: 2 days 6 hours ago
Joined: 2017-06-30 02:46
Hi MT_dialog ,

Hi MT_dialog ,

I have tested deep sleep with development, everything is running good.
And I add some testing port in function "adv_data_update_timer_cb()", "user_app_adv_start()" and "user_app_adv_undirect_complete()". It runs OK in development mode.

After burn it into OTP, running with checking testing port,
confirm that it is fail to copy firmware from OTP after deep sleep.
could you give me some clue ?
In software,
#define CFG_LP_CLK LP_CLK_RCX20
And in OTP header, what influences is "0X47F70 Package Used"?

Thank you

MT_dialog
Online
Last seen: 51 sec ago
Staff
Joined: 2015-06-08 11:34
Hi xuguiyhong,

Hi xuguiyhong,

Do you set the application flags to "Yes" in the OTP header in order for the primary bootloader to be aware that there is fw in the OTP ?

The #define that you have set is to define the low power clock that your device is going to use, if you are under buck configuration then the RCX20 oscilator is a valid option and you can use it, the field that you are refering (Package Used) is allready burned and identifies the kind of package of the current 580.

Thanks MT_dialog

xuguizhong
Offline
Last seen: 2 days 6 hours ago
Joined: 2017-06-30 02:46
Hi MT_dialog ,

Hi MT_dialog ,

Of course, I set the application flags to "Yes" in the OTP header.
And anything works OK except deep sleep waking up.

I have tried any ways to do it. But fail.
Could you send me a demo project with BLE timer waking up deep sleep(not button waking up)?
Then I burned it into OTP for a testing.

Thank you

MT_dialog
Online
Last seen: 51 sec ago
Staff
Joined: 2015-06-08 11:34
Hi xuguizhong,

Hi xuguizhong,

Attached a modified version of the app_ble_sleepmode with a timer along with the header for the OTP, the device advertises for 10 seconds and sleeps for additional 10 seconds and wakes up via a kernel timer.

Thanks MT_dialog

Attachment: 
xuguizhong
Offline
Last seen: 2 days 6 hours ago
Joined: 2017-06-30 02:46
Hi MT_dialog ,

Hi MT_dialog ,

Thanks for your DEMO.

I have burned it into OTP. It works.

I compared my software with your DEMO. Next is different.
Could you show me if they are correct?
(
again,
1. my software can work in OTP with extend sleep mode.
2. work in system RAM debug mode with deep sleep mode "#define CFG_DEVELOPMENT_DEBUG"
3. In OTP version, it can go into deep sleep, after BLE timer, it can touch waking up action(can`t catch port initial after waking up).
But can`t keep running.
)

1. different in file "user_modules_config.h"
#define EXCLUDE_DLG_GAP (0)
#define EXCLUDE_DLG_TIMER (0)
#define EXCLUDE_DLG_MSG (1)
#define EXCLUDE_DLG_SEC (1)
#define EXCLUDE_DLG_DISS (1)
#define EXCLUDE_DLG_PROXR (1)
#define EXCLUDE_DLG_BASS (1)
#define EXCLUDE_DLG_FINDL (1)
#define EXCLUDE_DLG_FINDT (1)
#define EXCLUDE_DLG_SPOTAR (1)
#define EXCLUDE_DLG_CUSTS1 (1)
#define EXCLUDE_DLG_CUSTS2 (1)

2. different in setting for the system startup sleep delay
I have called arch_startup_sleep_delay_set(0) in function mnf_data_init().
(Base on waveform of your demo from scope, power start time between power on and first advert is about 130ms,
but deep sleep time is about 2.11 second. So I need to short down it to 0 delay)

3. different in advertise type.
I have changed undirected advertise to non connectable advertise.
Say,

Demo:
cmd = app_easy_gap_undirected_advertise_get_active();
...
app_easy_gap_undirected_advertise_start();

My software:
cmd = app_easy_gap_non_connectable_advertise_get_active();
....
app_easy_gap_non_connectable_advertise_start();

4.different in file "da1458x_config_advanced.h"
#define CFG_BOOT_FROM_OTP
I add one function to read data from OTP header in function mnf_data_init().

MT_dialog
Online
Last seen: 51 sec ago
Staff
Joined: 2015-06-08 11:34
Hi xuguizhong,

Hi xuguizhong,

What i can see that might affect the waking up procedure is the fact that you 've altered the default sleep time when the device boots up, are you using an XTAL on your board ? You see the 2 seconds that are the default value in the SDK are there in order to let some time for the XTAL32 in order to settle, so the device doesn't go to sleep. If the device is not properly settled then the low power clock can cause different kind of issues on the system. Also be aware that this time is mandatory for XTAL32 and not when using the internal RCX. Other than that i dont see anything that could cause problems, the exclusion of different modules depends on your project, if you dont use profile or security of the message API then you can exclude those module and replace them with custom functionallity, regarding different type of advertising this will not affect you, and the CFG_BOOT_FROM_OTP will just read the OTP values from sysram and not directly from OTP.

Thanks MT_dialog

xuguizhong
Offline
Last seen: 2 days 6 hours ago
Joined: 2017-06-30 02:46
Thank you.

Thank you.

I am using internal RCX. (#define CFG_LP_CLK LP_CLK_RCX20 )
Can I set the system startup sleep delay to 0 ?
If not ,what is min value ?

MT_dialog
Online
Last seen: 51 sec ago
Staff
Joined: 2015-06-08 11:34
Hi xuguizhong,

Hi xuguizhong,

Since you are using the RCX then there is no need to wait for two seconds in order for the XTAL32 to settle since you dont have one. Also in your previous post you mentioned something that i cannot understand, what exactly do you mean "can't catch port after initial after waking up" ?

Thanks MT_dialog