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:
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.
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
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.
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.
当我使用ARCH_SLEEP_OFF, ran MDK debug, timeout_cb() function worked and I could debug the program and set breakpoints.