如何知道设备是从深度睡眠中唤醒的

了解更多FAQsTutorials

16个职位/0个新职位
Last post
brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
如何知道设备是从深度睡眠中唤醒的

亲爱的Dialog,

In my project, I want to seperate normal reset and wakeup from deep sleep mode. How to do it?

谢谢。

设备:
PM_Dialog
Offline
Last seen:4 hours 41 min ago
Staff
加入:2018-02-08 11:03
Hi brent_zheng,

Hi brent_zheng,

Could you please try to explain a bit more your question? It would be very helpful if you are able to clarify it in order to understand what you are trying to accomplish.

Thanks, PM_Dialog

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

我的项目设计是:

1安装电池后,设备将进入深度睡眠状态;

2. When user press a key which connect to one GPIO, the device will wakeup and start BLE advertise.

Because wakeup from deep-sleep was similar as normal reset, I want to know are there any way to seperate them?

谢谢。

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
如果一些内存空间可以

如果一些RAM空间可以在从深度睡眠中唤醒时保留数据,我可以在进入深度睡眠之前设置一些状态。

Or if some registers can read the power on reason, such as power on by normal power-on reset, hardware fault, wdg, wakeup etc. It also is ok, I can read the register after power on.

PM_Dialog
Offline
Last seen:4 hours 41 min ago
Staff
加入:2018-02-08 11:03
Hi brent_zheng,

Hi brent_zheng,

在深度睡眠模式下,所有电源域关闭,包括所有系统内存单元。无法保持可恢复的连接。系统将仅从外部中断(唤醒时硬件重置)或上电重置源唤醒。此外,在这种模式下还有一个OTP拷贝(如果从OTP引导)。在SDK6中,有一个可用的API,叫做arch\u set\u deep\u sleep(bool ext\u wakeup)。此API激活深度睡眠模式,系统可以在POR(上电复位)或外部唤醒中断条件下再次引导。

ext_wakeup à External wake-up interrupt flag:

  • 正确:外部中断可以唤醒并重新启动系统
  • false: no external interrupt can wake-up and reboot the system

Thanks, PM_Dialog

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

Yes, I know the logic about deep-sleep. My question is How to know whether the device is power on by wakeup or not?

谢谢。

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
我的SDK是6.0.4

我的SDK是6.0.4

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

你知道我的问题吗?如何通过从深度睡眠中醒来来知道设备是否开机。

期待您的回复。

顺致敬意,

布伦特·郑

PM_Dialog
Offline
Last seen:4 hours 41 min ago
Staff
加入:2018-02-08 11:03
Hi brent_zheng,

Hi brent_zheng,

First of all, I would strongly recommend you to download and use our latest SDK for DA14585/6 family products which is version 6.0.10 You can easily download it form our support portal. After that, my recommendation is to have a look at the ble_app_sleepmode example of the SDK which is located under \projects\target_apps\ble_examples SDK path. In this example, please check the app_button_enable() function which enables the wake-up controller before the device enters the sleep mode. You can select the GPIO that you could detect the wake-up interrupt with the wkupct_enable_irq() function. You can also configure the polarity and the debouncing time as well. Since the device goes into sleep and you send an interrupt to the wake-up controller, the callback function which is registered into wkupct_register_callback() will be triggered. So, by this way you will know if the check wakes up from sleep. Could you please let me know if your plan is to burn the OTP? 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. When the DA14585 is configured in deep sleep mode only the wakeup controller or the POR circuit remains switched on depending on the option selected. 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.

Thanks, PM_Dialog

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

谢谢你如此详细的答复。我下载了6.0.10SDK并检查了ble\u app\u sleepmode示例,在这个示例中没有深度睡眠,只有延长睡眠。在我的代码中,我们实现了深度睡眠,并将代码烧录到flash中,我们可以进入深度睡眠,然后按按钮唤醒,这些功能都很好地工作。在这种情况下,系统将执行冷启动,代码将从flash复制,因此它仍然可以调用从wkupct\u register\u callback()注册的回调吗?

谢谢。

PM_Dialog
Offline
Last seen:4 hours 41 min ago
Staff
加入:2018-02-08 11:03
Hi brent_zheng,

Hi brent_zheng,

If you have your firmware burnt into the SPI, the bootloader is executed first upon the wakeup, so the firmware will be copied into the RAM. That’s why this procedure is working.

Thanks, PM_Dialog

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

Yes. So from past message exchanges, you should have got my situation. Below I'll summary again, could you please give me an adivce about how to know whether the device is powered on by wake up from deep-sleep?

当前SDK:6.0.4,如果需要我们可以升级

Use SPI Flash

已配置按键从深度睡眠中唤醒。设备可以进入深度睡眠并成功从深度睡眠中唤醒。

Problem is: After wakeup from deep-sleep, the system execute cold-boot, similar as POR, WDT reset, hard-reset and soft-reset. I don't how to get power on reason from anywhere. I checked the 14585 spec and can not find any register related with this. Are there some ARM register keeped the power on reason, and if yes how to read it?

希望下次我能得到最终答案,非常感谢!

PM_Dialog
Offline
Last seen:4 hours 41 min ago
Staff
加入:2018-02-08 11:03
Hi brent_zheng,

Hi brent_zheng,

The定时器and the POR_PIN_REG are the only registers that will retain their values between resets and during deep sleep and can be used to store application data if the functionality is not used. The default value of the POR_TIMER_REG is 0x18, so you can check as soon as possible in your application (for example after the device has booted) the value of POR_TIMER_REG. Since the value of the POR_TIMER_REG is the default it means that we woke up from a POR. Please check a very simple example in order to check if you woke up from POR or HW reset/deep sleep

void user_app_on_init(void){…/*检查我们是否从POR或HW重置/休眠中醒来这是我们第一次醒来更改值并进入休眠,因为POR_TIMER_REG的值是默认值,这意味着我们从POR*/if(GPIO_GetPorTime()==0x18){GPIO_SetPorTime(0x19);/*配置唤醒引脚*/arch\u set\u deep\u sleep(true);else/*配置唤醒引脚*..}

如果条件为真,那么寄存器的值将更改,设备将配置唤醒引脚并进入深度睡眠,等待外部唤醒,使设备处于深度模式状态。应用唤醒信号后,设备将重置,代码执行相同的检查,但条件将不再为真。

Thanks, PM_Dialog

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

非常感谢!我将测试它immediately.

brent_zheng
Offline
Last seen:7个月1周前
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

好的,测试是否正常。第一次上电,数据为0x18。从深度睡眠/硬件重置中唤醒,数据为0x19。

谢谢。

PM_Dialog
Offline
Last seen:4 hours 41 min ago
Staff
加入:2018-02-08 11:03
Hi brent_zheng,

Hi brent_zheng,

很高兴你解决了问题,谢谢你接受我的回答。

Thanks, PM_Dialog