What are Application Timers?
Fast response to asynchronous external events is the most important function of real-time, embedded applications. However, many of these applications must also perform certain activities at pre-determined intervals of time.
ThreadX application timers provide applications with the ability to execute application C functions at specific intervals of time. It is also possible for an application timer to expire only once. This type of timer is called a one-shot timer, while repeating interval timers are called periodic timers.
Each application timer is a public resource. ThreadX places no constraints on how application timers are used.
What is the Application Timer interval?
In ThreadX time intervals are measured by periodic timer interrupts. Each timer interrupt is called a timer tick. The actual time between timer ticks is specified by the application, but 10ms is the norm for most implementations. The periodic timer setup is typically found in the tx_initialize_low_level file.
It is worth mentioning that the underlying hardware must have the ability to generate periodic interrupts for application timers to function. In some cases, the processor has a built-in periodic interrupt capability. If the processor doesn’t have this ability, the user’s board must have a peripheral device that can generate periodic interrupts.
ThreadX can still function even without a periodic interrupt source. However, all timer-related processing is then disabled. This includes timeslicing, suspension time-outs, and timer services.
What is the Application Timer accuracy?
Timer expirations are specified in terms of ticks. The specified expiration value is decreased by one on each timer tick. Because an application timer could be enabled just prior to a timer interrupt (or timer tick), the actual expiration time could be up to one tick early.
If the timer tick rate is 10ms, application timers may expire up to 10ms early. This is more significant for 10ms timers than 1 second timers. Of course, increasing the timer interrupt frequency decreases this margin of error.
When are Application Timers executed?
Application timers execute in the order they become active. For example, if three timers are created with the same expiration value and activated, their corresponding expiration functions are guaranteed to execute in the order they were activated.
Are there any limitations while using Application Timers?
By default, application timers execute from within a hidden system thread that runs at priority zero, which is typically higher than any application thread. Because of this, processing inside application timers should be kept to a minimum.
It is also important to avoid, whenever possible, timers that expire every timer tick. Such a situation might induce excessive overhead in the application. As mentioned previously, application timers are executed from a hidden system thread. It is, therefore, important not to select suspension on any ThreadX service calls made from within the application timer’s expiration function.
Where can I find more information?
You can find more information on the ThreadX user manual, available on the Synergy Gallery in the X-Ware zip file here: https://synergygallery.renesas.com/ssp/support#read
©1997-2015 by Express Logic, Inc. All rights reserved. This document and the associated ThreadX software are the sole property of Express Logic, Inc. Each contains proprietary information of Express Logic, Inc.