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

timer vs app_timer

I am trying to understand the difference between the timer driver and the app_timer library. First of all: It seems like timer and app_timer are two entirely different things. One is based on the RTC, the other one is not. But why are they then named in such a similar way?

When should I use app_timer and when the timer driver? The documentation is really poor on this part.

  • Hi Raphael,

    The RTC runs (runs on 32KHz oscillator) at much lower frequency compare to the normal TIMER (runs on 16MHz oscillator). So when you want to count time but more like real time (seconds, minute etc) you should use the RTC (or the app timer). When you want to count time more precisely, down to nano and micro second, then you should use the timer driver.

    I agree that the naming is quite confusing. It came from the past that we had only the app timer before and then we added the timer driver from SDK v7.x

  • app_timer is a module that is usually used with the softdevice. In most of our examples app_timer will use RTC1 (since this resource isn't used by the softdevice) and it allows you to schedule multiple timers, all using RTC1, to be used for different things in your application. The BLE examples provided in the SDK initialize and use the app_timer module for timers like (when to renegotiate connection parameters). But you can use it as well for some of your application specific timers and be sure that you wont interfere with the softdevice or anything else.

    i believe the timer is just a driver for our timer peripheral (which uses HFCLK). the softdevice will use some timers so you need to be careful. also maybe the example app you are using as a template uses some timers.. you need to check this carefully (softdevice spec, look through example code). otherwise you will get some bad behavior.

  • I think it would be great to either rename app_timer or timer driver or make the distinction between "drivers" and "libraries" much clearer in the docs. It seems to me like it is meant like a layer architecture where libraries are on top of drivers. This however is not so clear from the beginning when reading the SDK docs at first.

Related