[sdk5]problem about ext_sleep

32 posts / 0 new
Last post
kurbylee
Offline
Last seen:3 years 6 months ago
加入:2014-11-05 09:10
[sdk5]problem about ext_sleep

Background
1>project name: projects\target_apps\ble_examples\ble_app_profile
2>#undef CFG_DEVELOPMENT_DEBUG in da1458x_config_basic.h
3>for simplify the problem,comment the line ://#include "custs1.h" in user_profiles_config.h;
4>change value of app_default_sleep_mode to ARCH_EXT_SLEEP_ON in user_config.h
const static sleep_state_t app_default_sleep_mode=ARCH_EXT_SLEEP_ON;
5>compile and burn into external flash;

Result:
1>Phone will cann't scan the DA except just at power DA;
2>After powered DA,I scan use phone as soon as quick,I will find DA,but connect fail; and can't scan DA any more except reset DA;

Background 2:
Base on Background above,open watchdog, and toggle a led in init, I found that the chip will reset again and again ,so phone will always
scan DA but connect failed.

how I can use ARCH_EXT_SLEEP_ON correctly??

Keywords:
Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi kurbylee,

Hi kurbylee,

我已经测试了你的设置,它似乎工作好。我的年代uppose that you are using Smart Snippets to burn your SPI, do you make your device bootable when you are promted from Smart Snippets ? After burning the flash do you reset your board in order for the bootloader to run and boot from your SPI ? By setting the app_default_sleep_mode to ARCH_EXT_SLEEP_ON is enough to set your device to extended sleep. Are you able to see your device correctly when you dont use sleep mode?

Thanks MT_dialog

kurbylee
Offline
Last seen:3 years 6 months ago
加入:2014-11-05 09:10
HI,MT_dialog

HI,MT_dialog
1> Yes, I use Smart Snippets(ver 3.9) to burn ble_app_profile_580.hex into SPI,SDK ver is DA1458x_SDK_5.0.3
2>I had not use bootloader(secondery bootloader.hex),just burn ble_app_profile_580.hex use smartsnippert and make bootable; I can see the bootable flag added(8bytes begin with 7050)
3>After burn , I always reboot the board by repower;
4>If I change app_default_sleep_mode to ARCH_EXT_SLEEP_OFF,It will works very well;
5>when I use sdk3.0.8,no problem occured,whether define/undef CFG_EXT_SLEEP

ps:I open the same project inDA1458x_SDK_5.0.2.1,and then get same result as in sdk5.3:(
ths kurbylee

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi kurbylee,

Hi kurbylee,

I tested your setup again with a fresh 5.0.3 SDK and burn the image to the flash, it booted normally in reset and by removing the power. Are you able to donwload code by using keil, if yes is the device advertising as it should be ?

Thanks MT_dialog

kurbylee
Offline
Last seen:3 years 6 months ago
加入:2014-11-05 09:10
Thanks MT_dialog for your

Thanks MT_dialog for your information.
But I have not resolved the problem:
I burn the app hex with complied with app_default_sleep_mode=ARCH_SLEEP_OFF by smartSnippets 3.9, I can get expected result that the DA is running normal and android phone can scan/connect/access char it ;
if I change app_default_sleep_mode=ARCH_EXT_SLEEP_ON, and I can scan DA once only at time of DA powering.and then phone will never find DA;

Today , I do anthor test,I add a led toggle in main_func:(P07 is connected a led)
1>app_default_sleep_mode=ARCH_SLEEP_OFF in user_config.h
#undef CFG_DEVELOPMENT_DEBUG
#define CFG_WDOG in da1458x_config_basic.h (for more tests:))
2>in arch_main.c:
int main_func(void)
{
sleep_mode_t sleep_mode;
system_init();
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_7, OUTPUT, PID_GPIO, false );
while(1)
{
uint32_t i;
........................
if (((!BLE_APP_PRESENT) && (check_gtl_state())) ||
(BLE_APP_PRESENT))
{
GPIO_SetActive(GPIO_PORT_0, GPIO_PIN_7);
i=0xfffff;
while (i)i--;
//Disable the interrupts
GLOBAL_INT_STOP();
......................
......................
......................
GPIO_SetInactive(GPIO_PORT_0, GPIO_PIN_7);
i=0xfffff;
while (i)i--;
GLOBAL_INT_START();
}
.....
}
3>now,I can see the led is shinning,and phone will cann't scan it(app_default_sleep_mode=ARCH_SLEEP_OFF)

4>if I make app_default_sleep_mode=ARCH_EXT_SLEEP_ON, phone will scan and connect it now;

So I'm confused with the result :
when I add led toggle,DA is normal with app_default_sleep_mode=ARCH_EXT_SLEEP_ON; (it will disconnect after some seconds because of WDOG)
when I remove led toggle,DA is normal with app_default_sleep_mode=ARCH_SLEEP_OFF;

I think there is a strick related with Timer/Inteval and so on... for set app_default_sleep_mode ,but I have not find it:(

another information : when I undef wdog, the led will shinning 5 times and then keep light with app_default_sleep_mode=ARCH_EXT_SLEEP_ON

Another infor: By toggle led, I found that the app into infinit loop while(!ble_deep_sleep_stat_getf());====>in func sleep_mode_t rwip_sleep(void)

kurbylee
Offline
Last seen:3 years 6 months ago
加入:2014-11-05 09:10
Compared sdk5.03 and sdk3.0.8

Compared sdk5.03 and sdk3.0.8 files one by one, finally I found the culprit.
just chang SetWord16(RF_ENABLE_CONFIG13_REG, PREF_RF_ENABLE_CONFIG13_REG);
to SetWord16(RF_ENABLE_CONFIG13_REG, 0);
in func rf_nfm_disable,
Everything come back to OK.

ggotta
Offline
Last seen:1 year 10 months ago
加入:2016-02-20 20:10
Dear Dialog team,

Dear Dialog team,
Can you explain how does it effects? What is correct?

sprhawk
Offline
Last seen:3 years 1 month ago
加入:2016-03-03 17:25
Are you sure this is the

Are you sure this is the reason of your question ?

I encountered the exact problem of yours.

我的年代earched though, the rf_nfm_disable is called nowhere, so I think it is not the reason .

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi ggotta,

Hi ggotta,

Can you please explain what your problem is ? In the SDK 5 if you want to enable the 580 in sleep mode all you have to do is to set your default sleep mode to ARCH_EXT_SLEEP_ON. The rf_nfm_disable has to do with the near field mode operation and not the sleep operation. The function isn't invoked in the SDK by default its just the API for disabling the near field mode if enabled.

Thanks MT_dialog

ggotta
Offline
Last seen:1 year 10 months ago
加入:2016-02-20 20:10
Hi,

Hi,
Thanks for the details.
I enabled extended sleep mode and flashed the DA. After that I was not able connect via JTAG. But later I have gone through some more answers I found the solution. It is working now.
-gotta

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Hi Ggotta,

Hi Ggotta,

我遇到和你同样的问题,使EXT_SLE之后EP_ON, my phone can't scan the DA now except power on DA time.

How you solve the issue finally? Is it true to only change:
just chang SetWord16(RF_ENABLE_CONFIG13_REG, PREF_RF_ENABLE_CONFIG13_REG);
to SetWord16(RF_ENABLE_CONFIG13_REG, 0);
in func rf_nfm_disable

Or other time setting is also necessary?

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi smdzjl007,

Hi smdzjl007,

As mentioned above in the previous comment, the rf_nfm_disable doesn't have to do with the sleep but with the near field mode which is disabled by default. In order to put the 580 in sleep mode only the app_default_sleep_mode = ARCH_EXT_SLEEP_ON; is enough to put the device in sleep mode. What is the SDK that you are using, and are you experincing this on a dev kit or on a custom board ? If you are able to scan the device only for a couple of seconds, then either something is wrong with your low power clock or the debuuger stays attached to your device and prevents it from going to sleep if you are using an SDK prior to the SDK 5.0.4.

Thanks MT_dialog

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Dear MT_dialog team,

Dear MT_dialog team,

Thanks for your help. Yes, I do find out that modification within rf_nfm_disable function doesn't work at all. I am using SDK 5.0.3. How to locate the problem is related with low power clock or other reason? Should I upgrade to SDK 5.0.4?

Another question, after DA14580 enter to sleep mode, what timer setting to control the wake up from sleep? what timer to control wake up duration?

Thanks & Best regards,

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi smdzji007,

Hi smdzji007,

The rf_nfm_disable() function doesn't have to do anything with the sleep, if you move to the new SDK 5.0.4 the debugger isn't disabled during sleep so your device should continue advertise even if the debugger stays attached. If by moving into the new SDK doesn't help and you have a custom board check the setting of your LP clock should be either XTAL or RCX, if you are operating under buck mode and you switch to RCX and then you are able to see advertising, then your problem is the external XTAL32 that you have on your custom board.

The SDK takes care of how long the device will stay in sleep mode and when to wake up, all you have to do is set the advertising and connection intervals and the SDK will take care of the rest and configure the system to wake up on time and sleep as well.

Thanks MT_dialog

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Thanks, MT_Dialog team, very

Thanks, MT_Dialog team, very timely feedback!

I tried to modify user_config.h for advertising and connection intervals as below, actual user_connection_param_conf is not changed:

static const struct advertise_configuration user_adv_conf = {
.addr_src = GAPM_PUBLIC_ADDR,
.renew_dur = 0,
.addr = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6},
.intv_min = 1000, // 625 ms (1000*0.625ms)
.intv_max = 2000, // 1250 ms (2000*0.625ms)
.channel_map = 0x7,
.mode = GAP_GEN_DISCOVERABLE,
.adv_filt_policy = ADV_ALLOW_SCAN_ANY_CON_ANY,
.peer_addr = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6},
.peer_addr_type = 0,
};

static const struct connection_param_configuration user_connection_param_conf = {
.intv_min = MS_TO_DOUBLESLOTS(20),
.intv_max = MS_TO_DOUBLESLOTS(100),
.latency = 0,
.time_out = MS_TO_TIMERUNITS(125),
.ce_len_min = MS_TO_DOUBLESLOTS(0),
.ce_len_max = MS_TO_DOUBLESLOTS(0),
};

But the test result is still failed, the device can broadcast BLE advertisement message for very short time, then sleep and my smartphone can't scan the device anymore.

what else structure should I modify to make it sleep/wakeup as normal wearable device?

Thanks & Best regards

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi smdzj007,

Hi smdzj007,

I would suggest not to modify anything (in order to verify that the reason for the 580 not advertising is not the fw), just take ble example from the 5.0.4 as is and run it to sleep mode (const static sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;) in the user_config.h file also run the same example with const static sleep_state_t app_default_sleep_mode = ARCH_SLEEP_OFF; and check if you do that is the device advertising and if it does you will have to set the sleeping mode always to off (ARCH_SLEEP_OFF). Do the above and let me know. Also please let me know if you are using a custom board or a dev kit and if you are using an external XTAL or you are operating with the RCX.

Thanks MT_dialog

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Thanks, MT_Dialog team!

Thanks, MT_Dialog team!

I upload my .hex file to other dialog support engineer, he see the same result as me.
https://support.dialog-semiconductor.com/smartsnippets-spi-flash-program...

He is using 580 dev kit pro. My design is also use dialog reference design with external XTAL clock. It works fine if switch off sleep.

Anyway, I will try again to download 5.0.4 sdk example to see any difference or not.

In the meanwhile, can you confirm my previous question about advertising and connection intervals adjustment? Are those 2 structures correct? Is my interval setting valid?

Thanks & Best regards

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Hi MT_Dialog team,

Hi MT_Dialog team,

After checking with previous colleague, he told me that our design is based on dialog wechat sdk reference design:
https://support.dialog-semiconductor.com/connectivity/reference-designs?...

I tried to download wechat sdk reference design and run it to sleep mode (const static sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;) in the user_config.h file. The problem is the same as mine, device sleep and can't be discovered by smart phone app: AirSyncDebugger

Two questions here:
- did wechat SDK reference design tested for extended sleep mode?
- how to replace wechat SDK reference design used dialog SDK to 5.0.4 standard SDK?

Thanks & Best regards,

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi smdzjl007,

Hi smdzjl007,

- Yes, the wechat is tested to operate under extended sleep mode and i am also able to see the advertising string when the device is in sleep mode.

——我不问题,你的意思是如何replace the fw ? You can run directly one of the SDK examples via JTAG or you can download the .hex file of the examples via UART or if you have a flash, you can burn the flash and upon power up the 580 will download the code from the flash.

Thanks MT_dialog

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Hi MT_Dialog team,

Hi MT_Dialog team,

The question is coming from fact that: wechat reference design was released with 14580 SDK version x at Nov'15, as there is new 14580 sdk version 5.0.4 recently, if I need upgrade wechat reference design sdk source into 5.0.4 sdk, what procedure should I do?

Thanks & Best regards,

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi smdzji007,

Hi smdzji007,

Depending on where the the fw is located and if the fw that you are using is the wechat as provided by dialog, you should compile the code and download it to your device. If the device is using a flash memory or an EEPROM memory in order to load the fw you can erase and reburn the device via the Smart Snippets tool, either via JTAG or via UART (depending on the interface your device has available). In case the wechat is burned in OTP you wont be able to update the OTP since you can only program it once. You can also test the new source code via downloading the new fw directly to the sysram via keil and the JTAG interface (again if this interface is available on your device, you can also debug the code in that case) also you can download code into the sysram via UART through the Smart Snippets tool.

Thanks MT_dialog

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Dear MT_dialog,

Dear MT_dialog,

Today I ask my colleague to measure clock output signals. You can find attached 3 jpg.
If disable sleep, we can measure both 32KHz and 16MHz clock: 32K_withoutsleep.jpg and 16M_withoutsleep.jpg
If enable sleep, only can see 32KHz signal:32K_withsleep.jpg

I am using SDK5.0.4, the ble_app_sleepmode from SDK example folder. According to example code, the wakeup duration is 0.5s, so it should be very quick. But my test result looks that the 14580 failed to wakup and I can't scan the 14580 device from my smartphone

Can you help to give hints for more trouble shooting?

BTW, should I config CLK_16M_REG as XTAL16_BIAS_SH_ENABLE register before/after sleep?

Thanks & Best regards

Attachment:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi smdzji007,

Hi smdzji007,

The ble_app_sleepmode falls to permanent sleep after a specific period of time (a few seconds) and the XTAL16 is disabled when sleep is enabled, you can try using a another project that doesn't sleep constantly but wakes up in predefined periods in order to advertise and check again. You dont have to configure the CLK_16M_REG explictly, the SDK will take care of that in the periph_init() function.

Also the specific project implements a button press that when pressed the device wakes up and continiues to advertise, have to tryied to press that button in order to wake up the device.

Also please dont post questions in irrelevant topics, you can always create a new thread if theres any follow up question.

Thanks MT_dialog

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Hi MT_dialog,

Hi MT_dialog,

Thanks to confirm ble_app_sleepmode behavior is correct in my board, so what should I do to enable automatic wake up after 14580 enter extended or deep sleep? To add one XTL32 timer call back function or what else? Which sample project should I use for reference?

The reason for me to post question here is because I found my problem is relevant with current thread topic, and I can't find where is the button to create new thread. If my posting cause any in-convenience to you, I need say apology to you.

Thanks & Best regards,

Qinjiny_Dialog
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2016-11-01 05:47
Hi smdzjl007,

Hi smdzjl007,

You could try functionapp_easy_timerif the sleep time you specify is not too long(like under 5min)

BR,

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Thanks for feedback, Qinjiny

Thanks for feedback, Qinjiny from Dialog team,

As previous support engineer said, the XTAL16 clock is disabled when sleeping is enabled, whether app_easy_timer can work normally? Should I write one call back function to enable XTAL32 clock by registering call back function like below?

static const struct arch_main_loop_callbacks user_app_main_loop_callbacks = {
.app_before_sleep = my_app_enable_XTAL32_clock,
.app_resume_from_sleep = my_app_disable_XTAL32_clock,
};

smdzjl007
Offline
Last seen:3 years 10 months ago
加入:2015-08-04 15:07
Hi MT_Dialog,

Hi MT_Dialog,

I re-study the ble_app_sleepmode example and found below definition within da1458x_config_advance.h

/****************************************************************************************************************/
/* Wakeup from external processor running host application. */
/****************************************************************************************************************/
#undef CFG_EXTERNAL_WAKEUP

/****************************************************************************************************************/
/* Wakeup external processor when a message is sent to GTL */
/****************************************************************************************************************/
#undef CFG_WAKEUP_EXT_PROCESSOR

Not sure whether it is aligned with your previous answer that the ble_app_sleepmode fall into permanent sleep until external button press trigger wake up. So, how this example code to undefine the external wake up but using external wake up?

Confusing for me

Best regards,
smdzjl

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi smdzjl007,

Hi smdzjl007,

The definitions that you see there, has nothing to do with the ble_app_sleepmode project but with the external wake up when the 580 runs in fully embedded mode (defined by the SDK). If you are interested to check the code that dictates that particullar project you can check the following:

  • user_app_adv_start() -> a ke_timer is started with adv_data_update_timer_cb() as a handler to execute when elapsed.
  • When time elapses adv_data_update_timer_cb() executes and stops the advertising procedure.
  • When the advertising procedure is stopped the user_app_adv_undirect_complete() handler is getting invoked.
  • In the user_app_adv_undirect_complete() the functions arch_ble_ext_wakeup_on() is called in order to prevent the waking up of the 580 in steady intervals and the app_button_enable() sets the wakeup timer and the corresponding GPIO that is used for waking up as well as the corresponding callbacks for the waking up events.

Thanks MT_dialog

Liang Yun Hao
Offline
Last seen:3 years 2 months ago
加入:2016-03-05 13:38
Hi MT_Dialog,

Hi MT_Dialog,

Now I use Da14580 pro kit, and I set the app_default_sleep_mode to ARCH_SLEEP_OFF. It can work well when I burned hex file to SPI falsh, press reset button and pull the daughter board away from mother board.(It's powered by external battery.) It can be scanned from my cellphone. But when I set app_default_sleep_mode to ARCH_EXT_SLEEP_ON, it cannot be scanned from my phone. Does any else code I have to set? Which oscilator does the chip use when it enter the sleep mode? Thanks.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Liang Yun Hao,

Hi Liang Yun Hao,

Please dont post questions in irrelevant topics, you can always create a new thread.

关于你的问题,尝试运行项目directly from keil with extended sleep on and check if you are able to see your device advertising, also try to do the same with an SDK example and check as well. When the device is in sleep mode the LP clock is used that means that the device operates either with the external XTAL32 or with the RCX, this option can be configured from the CFG_LP_CLK definition in the da1458x_config_advanced.h file.

Thanks MT_dialog

zhounaichun
Offline
Last seen:3 years 4 months ago
加入:2017-07-17 02:54
that's working!!!

that's working!!!
my problem : when i set extended sleep mode,my phone can't connect to my ble device,but if i set sleep_mode=ARCH_SLEEP_OFF, it's normal. then i change the value of CFG_LP_CLK(da458x_config_advanced.h) from LP_CLK_XTAL32 to LP_CLK_RCX20,that‘s is ok.
but i have a another problem that is when i set the sleep mode to deep sleep my phone will not find the ble device.
if anyone can tell me why?

SDK:5.0.3 5.0.4
device:not Unofficial device

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi zhounaichun,

Hi zhounaichun,

Well, if you are under development mode and you 've set the ARCH_DEEP_SLEEP_ON and you ve also changed the memory configuration to CFG_MEM_MAP_DEEP_SLEEP (undefine CFG_MEM_MAP_EXT_SLEEP and set the CFG_MEM_MAP_DEEP_SLEEP) then you should be able to test the fw in deep sleep mode. But to see the proper power consumption of the device you will have to burn the OTP with your fw, so in every wake up the image will be copied from the OTP to the sysram, since in deep sleep the sysram will be shut down.

Thanks MT_dialog