Software Timer

A timer provides the facility to measure time. SAM R34 has five hardware timers. Every component in MLS such as the RADIO, MAC, APP needs a timer, therefore, the timers need to be efficiently shared among all the components.

A software timer is used to provide the necessary abstractions for MLS to use the hardware timers. It manages the operation of the hardware timer, thus freeing the user from managing the hardware timers directly. The hardware timer TC0 is used in the stack to configure all the software timers.

The software timer provides a set of interfaces to initialize, create, start, and stop timers. The start of a timer function has parameters for measuring the time duration as well as a callback function. Once the duration of time has elapsed, the user-supplied callback function will be invoked.

More than one software timer can be started simultaneously. They are automatically sorted according to their duration and expiration accordingly. Along with running for a user-specified duration, the software timer module also keeps track of system time. System time is measured from the initialization of the software timer during Reset.

MLS currently supports a maximum of 25 software timer instances. It can be customized as per application requirements by changing the following macro in conf_app.h.

/* Number of software timers */
#define TOTAL_NUMBER_OF_TIMERS (25u)
Note: Changing the number of software timers requires a rebuilding of application firmware.