DA14681 goes into hibernation but after 2 wakeups it do not go again?

⚠️
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.wsdof.com/support。We’ll be fixing bugs / optimising the searching and tagging over the coming days.
16个帖子/ 0新
Last post
mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
DA14681 goes into hibernation but after 2 wakeups it do not go again?

嗨对话框

我正在使用Command的DA1468X在定制板上工作

pm_resume_sleep();
pm_set_sleep_mode(pm_mode_hibernation);

to put it in hibernation. It goes into hiberanation and wakeups with external GPIO interrupt but after waking up 2 times it do not go into hibernation.

Is it related to that logic that hibernation mode is for ship devices to customer . When customer on the device then this piecce of code is disabled?

Is my understanding right?

Keywords:
设备:
PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

您能否在使用PM_RESUME_SLEEP()和PM_SET_SLEEP_MODE()API的位置?要将设备放在休眠模式下,您应该使用PM_SET_SLEEP_MODE(PM_MODE_HIBERNATION)。请注意,休眠模式是用于将最终产品运送到市场的特殊模式,而无需排出电池。这是用于运输和存储最终产品的内容,我不建议您为开发或调试范围建议休眠。因此,如果您的产品不用于发货,G我会建议您使用睡眠模式,将睡眠模式扩展到system_init()中,原因是当系统从休眠状态唤醒时,系统重置并从一开始就重置并运行。This is not a software reset, it’s like a hardware reset, so the system will run the code from the start and the system_init() will be executed again (every time that the 680 wakes up from the hibernation. Also, the pm_resume_sleep will Restore the sleep mode of the system, which has been blocked via a call to pm_stay_alive()If you could provide more inputs regarding this issue, it would be very helpful.

谢谢, PM_Dialog

mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
I have understood that

我已经明白producti冬眠on shipping purposes , but i want to add a feature in my device to hibernate it when battery reaches a certain voltage and then wakes it up when charger is connected, which can be detected via GPIO.

I just want the method to implement this.

谢谢

PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

您能否在您使用pm_set_sleep_mode(pm_mode_hibernation)中的代码中注明您的代码?如您在初始帖子中提到的,设备可以进入休眠模式。但是2次醒来后发生了什么事?你能为我提供一些额外的投入吗?

谢谢, PM_Dialog

mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
在我输入PXP之后

我在输入PXP_Reporter任务后使用PXP_reporter,我使用ADC检查VBAT电压,然后使用这两个命令。

pm_resume_sleep();
pm_set_sleep_mode(pm_mode_hibernation);

And i need to ask that for entering hibernation mode two conditions need to met

1 - System must enter sleep mode

2 - VBAT must be low than dg_configBATTERY_LOW_LEVEL

?

PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

Since you are using battery in you design, if the voltage underflow, the system will automatically go into the hibernation mode. Looking at the SDK, the only place where the voltage level of the attached battery in monitored, is in apply_wifi() routine in sys_power_mgr.c file. Please search for the “Voltage underflow check” comment. If the battery voltage is too low (under dg_configBATTERY_LOW_LEVEL), the usb_charger_is_battery_low() will return true. To do so, if low_vbat is true, the current sleep mode will be changed to hibernation. Looking at the FreeRTOSConfig.h file the configPRE_STOP_PROCESSING() macro is empty, so you can hook you own functionality here. Please check the following implementation in order to declare a hook function:

In custom_config_qspi.h file, declare the battery voltage threshold as well as the battery type:

#define dg_configBATTERY_LOW_LEVEL (4000) // Set a threshold higher to power supply

#define dg_configbattery_type(battery_type_custom)

In FreeRTOSConfig.h file declare your hook function. For instance:

#define configpre_stop_processing(x)my_custom_callback_low_battery(x)

In the file of your choice, for instance in main.c, declare your hook function.

In apply_wifi() routine in sys_power_mgr.c file, modify the configPRE_STOP_PROCESSING macro accordingly:

if (sleep_period == 0) {

//允许添加应用程序代码的用户可定义的宏。

configPRE_STOP_PROCESSING(pm_current_sleep_mode); // Pass in the argument(s) of your choice

} else {

//允许添加应用程序代码的用户可定义的宏。

configpro_sleep_processing(sleep_period);

}

条件(VBAT_LEVEL

谢谢, PM_Dialog

mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
谢谢很多对话框。

谢谢很多对话框。

如果有任何问题来,我会实现它,我会回复这篇文章。

mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
I have tried above method but

我尝试过的方法,但系统没有进入睡眠状态。

So what i have done is that i have used this piece of code which check VBAT after every 6 sec and if VBAT is low that recommended voltage. It enters sleep.

Problem with this method was that i need to wait 2-3 secs to put system in hibernaton else it goes into hibernation and restarts.

g_VBAT_check_counter++;
if(g_VBAT_check_counter>=10)
{
battery_source bat = ad_battery_open();
raw_vbat = ad_battery_raw_to_mvolt(bat, ad_battery_read(bat));
if(raw_vbat<=3000)
{
printf("\nHibernating\n");
fflush(stdout);

sys_watchdog_notify(wdog_id);
OS_DELAY_MS(2000); // Do everything and get free
pm_resume_sleep();
pm_set_sleep_mode(pm_mode_hibernation);
}
g_vbat_check_counter = 0;
}

PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

Can you please remove the battery reading every 6 sec and test again the above implementation? The voltage underflow check will be down in apply_wfi() by default. Which SDK are you using?

谢谢, PM_Dialog

PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

Can you please remove the battery reading every 6 sec and test again the above implementation? The voltage underflow check will be down in apply_wfi() by default.

谢谢, PM_Dialog

mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
是的,我已经测试过这个

是的,我已经测试过这个,现在它正在完美工作。

谢谢对话框

PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

Glad that the provided implementation is working and thanks for accepting my answer.

谢谢, PM_Dialog

mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
I have another problem that

我有另一个问题,通过任何方法,DA14681进入休眠并留在休眠状态,如果它是PXP报告者循环的正常情况。在启动之前在PXP Reporter中输入第1次的循环,如果我尝试使其休眠,它会休眠,然后再次重新启动。知道这个的原因,

PXP Reporter is same as in example FW. I am using that project as base project for my project.

PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

Can you please clarify what you mean with “in normal for loop of PXP Reporter”?

谢谢, PM_Dialog

mahmed106
Offline
Last seen:2个月2周前
Joined:2019-05-03 17:28
In pxp_reporter_task function

In pxp_reporter_task function

for (;;)

这是我在谈论的主循环

PM_Dialog
Offline
Last seen:6小时12分钟前
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

我假设您明确地放置了DA14681和PM_SET_SLEEP_MODE(PM_MODE_HIBERNATION)被调用邮件循环。我是,你可以说明你在哪里使用这个api吗?可能由于挂起的中断,系统可能无法休眠。

谢谢, PM_Dialog