Hello Dialog,
I'm continuing work on an application based on the ble_app_peripheral example. I did a few current measurements and have a few questions about the ble-timer.
In my application i want to sample with different frequences. For example every 40 ms. After one second i want to send it to the computer.
The code works and i get the right values.
If there is a connection intervall, sometimes the timer for the adc measurement interrupt early than expected. On the picture you can see the issue. Actually the adc measuement should be after the connection event, but it is 10 seconds earlier. After that the time between to measurements is right again. This happens a few times and thats the reason why i get more values in a second that i want.
Do you have any idea how i can solve this problem.
另一个问题:定时器间隔的解决是什么?是否有可能获得例如65ms的间隔。目前我只有10毫秒的分辨率。使用BLE-TIMER非常重要,因为在两次测量之间想要睡眠。
Regards
David

Hi DavidW,
Well the ble timer have an accurancy of 10 ms and this is a minimum interval that you can set, so no you cannot have a timer of 65ms. Regarding the fact that the timer will trigger sometimes a bit earlier, like 10 ms or less this is observed in two cases:
But on the screenshot that you have attached it seems that what you are indicating is not a kernel timer (the second activity that you have marked as m2) this seems to be a connection event, and not a wake up due to a timer event.
Thanks MT_dialog
Hi MT_dialog,
thanks for the quick response.
Yes you're right with the connection event at M2.
So if I understood you correctly in my case the timer is set during an asyncronous event and cause of that i have this inaccuracy. Do you have any idea or is there a possibility to wait a time that i can set the timer not between two ticks?
只有在ADC测量附近有连接事件时才发生此问题。如果您说连接事件与内核计时器无关,为什么不会在连接事件后直接发生唤醒(ADC测量)?
Regards
David
Hi DavidW,
Actually what you are experiencing is mostly the second point i ve mentioned, the expiry of a timer is quite identical with a connection event (they both are events from the BLE core), i mean that if the timer happens to co-exist with a connection interval at some point the stack will execute both while the device is awake but in your case the connection interval occurs and the timer will go of in approximatelly 10 ms, so the scheduler will execute again both in order not to waste power in order to wake up again in order to execute the callback.
Thanks MT_dialog
Hi MT_dialog,
好的。谢谢你的好答案。
Is there a possibility to get the ble-timer from the connection intervall. Then i know if my adc and connection event timer will interrupt at the same time.
I prefer to do the measurement after the connection event, so i want to set the timer delay to x+1.
问候,
DavidW
Hi DavidW,
我不了解的一种方式avoid this from happening, even if you provide a value which is not a direct multiple of the connection interval, in time this event will eventually occur. An idea would also be to perform the adc measurement right after the connection interval by catching the BLE_EVT_END of each connection interval without using a timer. Please check the beacon implementation for catching the specific event in the user_on_ble_powered(), but this implementation will limit your sampling period on your connection interval.
Thanks MT_dialog