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

related to timer

Hi All, please explain me in understanding the following w.r.t to timers. I am novice in this field and i am trying to understand the 51822 Ble_app_hrs project

C:\Keil_v5\ARM\Device\Nordic\nrf51822\Board\pca10001\s110\ble_app_hrs\arm
  1. is each timer node array linked to user array and operational queue?
  2. how are user array and operational queues linked
  3. In this case, the scheduler is not linked to timer, if i see the code timer_list_insert is called by list_insertions_handler,which is called by timer_list_handler and now the code for timer list handler is as below void SWI0_IRQHandler(void) { timer_list_handler(); } please help me in understanding how this entire thing is linked.i mean at what time is the timers_init called and at what time is the timer_list_handler is called so that i can stitch all pieces for complete understanding of timers. Please help
  • The app_timer module is a somewhat complex module, which allows the user to add instances/handles (continuous or one-shot) that occur based on the "TICK" (timer increment) of the RTC peripheral. When one instance is expired, the timeout_handler callback is fired.

    This allows you to have several handlers that occur at different ticks (example, 1 ms / 100 ms / 1 second, etc), but they are all based on the RTC peripheral (which is f = 32.768 kHz)

    1. It's a choice from our side not to use dynamic memory allocation, meaning that all instances has to be allocated in compile-time. What you, as the developer, has to configure is:
    • APP_TIMER_MAX_TIMERS, amount of timer instances running in your system
    • APP_TIMER_PRESCALER, which is the prescaler setting (0 = ~30.51 us per TICK)
    • APP_TIMER_OP_QUEUE_SIZE, which is the queue size. See here for detailed info devzone.nordicsemi.com/.../
    1. The user array (define APP_TIMER_MAX_TIMERS) are the number of instances running in your application. The operational queue is the number of queued handlers that can be processed at the same time. This is normally only an issue if you're using different interrupt sources w/ different priority.

    2. The library is made to be used, not to understand each static function inside the library, but I fully understand why you want to know how the library works in detail. When you init the module using the APP_TIMER_INIT macro function, you also allocate memory based on the defines set 1). Then the initialization is done in two steps:

    • Create
    • Start

    You create the instance, and give it an ID + timeout_handler. You start the instance with an ID + instance options (repeated/oneshot, and interval in TICKS)

    You have two interrupts in this library:

    • RTC IRQHandler
    • SWI IRQHandler (Supervisor Call, read: Software triggered interrupt)

    The RTC is triggered by the Capture/Compare, and is given by the mathematical formula found in the Reference Manual. The library computes these values for each timeout handler.

    The SWI interrupt is triggered by function "timer_list_handler_sched" (NVIC_SetPending()), which is called in several places in the library.

    The RTC IRQHandler checks the timing of each instance, and if a handler has timed out (callback is to be fired), it fires the specific callback by calling timeout_handler_exec() with p_timer as input. The SVC/SWI interrupt is triggered when you for instance modify/create/start/stop any instances.

Related