HIDOFF 唤醒后 全局变量值会被重新初始化?

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
CaLi_4592466
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

1.当从 HIDOFF 模式下,唤醒后,APP 的程序会重启,重新运行,之前定义全局变量,在中断函数中进行累加,但在唤醒后会重新初始化为0?

那么如果需要保存 全局变量的值,只能存入flash?有什么其他的方法使变量不被 程序重新初始化?
2.wiced_power_save_store_state 该函数 参数是一个 uint16_t   的变量,是用来存储什么变量的?

0 点赞
1 解答
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

1. HIDOFF唤醒之后,系统会重启,并重新进行初始化。如果要保存变量值,可以将其存入到flash中。也可以使用wiced_power_save_store_state存储。

2. wiced_power_save_store_state可以存储任何需要的变量,并通过wiced_power_save_retrieve_state在wakeup的时候重新获取。

3. 是的,系统会根据当前情况自动选择是否进入low power模式。

在原帖中查看解决方案

0 点赞
7 回复数
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

请问你用的是哪个产品?

0 点赞

CYW20706, 开发板是 CYBT343206-EVAL 02,另外 CYW20706 进入 PDS 的示例代码有吗?

0 点赞
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

请参考下面的关于low power的文档,以及low power beacon的demo:

https://www.cypress.com/design-guides/cyw20706-cyw20735-and-cyw20719-low-power-modes

CYW20706 – BLE Low Power Beacon

0 点赞

你好,Owen,这个文档和连接我都看过了,但是并不能解答我下面的问题:

1.当从 HIDOFF 模式下,唤醒后,APP 的程序会重启,重新运行,之前定义全局变量,在中断函数中进行累加,但在唤醒后会重新初始化为0?

那么如果需要保存 全局变量的值,只能存入flash?有什么其他的方法使变量不被 程序重新初始化?
2.wiced_power_save_store_state 该函数 参数是一个 uint16_t   的变量,是用来存储什么变量的?

3. Low power Beacon 的示例应该使用的HIDOFF 的sleep 方式吧。

0 点赞
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

1. HIDOFF唤醒之后,系统会重启,并重新进行初始化。如果要保存变量值,可以将其存入到flash中。也可以使用wiced_power_save_store_state存储。

2. wiced_power_save_store_state可以存储任何需要的变量,并通过wiced_power_save_retrieve_state在wakeup的时候重新获取。

3. 是的,系统会根据当前情况自动选择是否进入low power模式。

0 点赞

2. wiced_power_save_store_state可以存储任何需要的变量,并通过wiced_power_save_retrieve_state在wakeup的时候重新获取。
当设备在HIDOFF 的 模式下时,关于使用这个wiced_power_save_store_state 函数时,我如果在 gpio 中断函数的callback 中,存入一个累加的数据,然后在 系统重启 后wiced_power_save_retrieve_state调用这个 函数,发现存进的值被清零了。
wiced_power_save_store_state 和wiced_power_save_retrieve_state 函数的使用有什么特殊的注意事项吗?

0 点赞
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

保存变量的问题在另一个帖子里已经回复过了,你可以看一下:wiced_power_save_start唤醒之后,如何继续往下跑

0 点赞