This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

app_timer issue

I'm developing an application based on SD130 1.0.0 (latest) and DevKit board with 51422 chip. The application uses timer for some synchronization purpose. Operation with timer are next:

  1. start timer for 2000 mS
  2. stop timer by some BLE event (in advertising report handler), ~500 mS after startind times, so timer has not expired yet.
  3. start the same timer immediately for 200mS.

But looks like timer continues counting up to 2000mS (timer handler is called every ~2000 mS). When I additionally call app_timer_stop() in timer handler for this timer then behavior is as expected - timer handler is called 200 + ~500 mS.

So, question: can be a problem calling app_timer_stop() in advertising report handler? Seems like timed isn't stopped or isn't started correctly there.

  • I have found the same thing that you found, And I strongly suspect that the app_timers are not designed in the way to start and stop from different interrupt contexts. You should start and stop them from same contexts because doing something from different priority level is considered as a different user operation.

    Please look into the example SDK\examples\ble_peripheral\ble_apps_hids_keyboard and see how the app_timer is initialized along with SCHEDULER module scheduler_init(); and timers_init();. That shows you how you can use APP_TIMER_APPSH_INITinstead ofAPP_TIMER_INIT

    I can clearly see the lack of documentation for this, and I will send a feedback for adding more documentation for APP_TIMER library for next releases.

Related