This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

timer can not trigger by right ticks

Hi all,

I create 4 timer in APP, and there seem only one timer (work in single shot mode) can not trigger by right ticks.

I add some log and find that:

  1. First I start this timer, timeout_ticks is 229376 (7s), then I get the current time by app_timer_cnt_get, it show the current time is 4 .
  2. When time out of this timer get the current time is 229382, it seem right.
  3. Then I start this timer against, timeout_ticks is 16384 (0.5s), the current time is 229386.
  4. But something wrong, I wait almost 7s, then it get timeout handler. And I also print the current time, it is 229393, it seems wrong, 229393 -229382 = 11,it is not 16384, but I wait almost 7s.
  5. Finally I start this timer against, timeout_ticks is 196608(6s),current time is 229398.
  6. But also get wrong current time of 229405 when the time out, but I think I wait about 6s to get this time out which seem right.

What's wrong? Please help me, thank you very much.

What I use is NRF52, and the SDK is nRF5_SDK_11.0.0, softdevice is s132.

Parents
  • Hi,

    All the values you print from your timeout handler (229382, 229386, 229393, 229390, 229405) are slightly larger than your initial timeout value (229376). This is because the timer continues to run (although it has triggered an interrupt on the timeout value) and there is some variation in how long it takes before getting to those places in the interrupt handler.

    As far as I can see, the timer triggers on the first value (229376) every time.

    When you call app_timer_stop() and app_timer_start() from interrupt context (APP_LOW or higher) the corresponding operations will be queued and run later in APP_LOW.

    Are you checking the return values of app_timer_stop() and app_timer_start()?

Reply
  • Hi,

    All the values you print from your timeout handler (229382, 229386, 229393, 229390, 229405) are slightly larger than your initial timeout value (229376). This is because the timer continues to run (although it has triggered an interrupt on the timeout value) and there is some variation in how long it takes before getting to those places in the interrupt handler.

    As far as I can see, the timer triggers on the first value (229376) every time.

    When you call app_timer_stop() and app_timer_start() from interrupt context (APP_LOW or higher) the corresponding operations will be queued and run later in APP_LOW.

    Are you checking the return values of app_timer_stop() and app_timer_start()?

Children
No Data
Related