请教app_easy_timer在周期性唤醒休眠时的正常用法

⚠️
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.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5 posts / 0 new
Last post
Richard
Offline
Last seen:2 years 8 months ago
加入:2017-01-08 04:10
请教app_easy_timer在周期性唤醒休眠时的正常用法

Hi,Dialog:
需求:用SPI接口外接传感器,需要定时每隔20s采样一次。程序工作在扩展休眠模式,我使用的是app_easy_timer()接口周期性的定时唤醒。现在需要先测试周期性唤醒功能 。
问题描述:在ble向外开始广播时调用app_easy_timer(2000, timeout_cb), 超时后,进入定时超时回调timeout_cb处理,下面是timeout_cb大概的实现
void timeout_cb(void)
{ ...
if( xx_timerid != 0 )
app_easy_timer_cancel(xx_timerid); //先取消

xx_timerid = app_easy_timer(2000, timeout_cb);//再启动
}

问题:(1)第一次唤醒后,回调函数中会调用取消定时器easy_timer_cancel(),然后功耗就升高了,大约在500+ua.这是什么原因,这段代码有没有问题?是不是定时器使用方法不正确导致?

(2)另一个问题是,以上的实现好像只能唤醒1-2次,后面无法正常唤醒,所以想知道这个定时函数的使用技巧是什么,有哪些注意的地方,
比如,在timeout_cb内是否还能调用app_easy_timer?

Keywords:
Device:
lanbu
Offline
Last seen:3年5个月前
加入:2017-10-27 04:44
I want to know the answer too

I want to know the answer too, When I open ARCH_EXT_SLEEP_ON, the app_easy_timer(2000, timeout_cb) function doesn't work. When the time is up, the program doesn't go into
timeout_cb() callback function.

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi Richard, landu,

Hi Richard, landu,

I would appreciate if you use the Chinese forum for posting in Chinsese since i am not able to understand the question. I can only assume that you are using the app_easy_timer with a value of 2000 and the callback never executes, i am not able able to replicate what you are mentioning, using the ble_app_peripheral project with ARCH_EXT_SLEEP_ON and changing the APP_ADV_DATA_UPDATE_TO to the value of 2000 and via using the arch_set_pxact_gpio() i am able to see the callback executing. So perhaps something else is the reason that you are not able to see the callback executing, where do you set the timer ? or how do you verify that the callback is never being invoked ?

Thanks MT_dialog

Richard
Offline
Last seen:2 years 8 months ago
加入:2017-01-08 04:10
Hi, MT_dialog,

Hi, MT_dialog,

Thanks for your timely response.
Sorry, I thought maybe English or Chinese would be OK. I've solved the problem yesterday. The reason for not triggering the callback is the place where I call the timer func. It should be called after the ble core reset. So I change to call app_easy_timer this func in "user_app_adv_start" then it works.

lanbu
Offline
Last seen:3年5个月前
加入:2017-10-27 04:44
I have solved the problem too

I have solved the problem too. I found that when I used the MDK debug online, downloaded and ran the program, timeout_cb() function didn't work. but when I exited the debug mode, it worked.
When I used ARCH_SLEEP_OFF, ran MDK debug, timeout_cb() function worked and I could debug the program and set breakpoints.