SYSTIMER: Overview

Arduino SYSTIMER

SYSTIMER
Overview

Overview

The SYSTIMER APP uses the SysTick interrupt to call user functions periodically at a specified rate or after a given time period expires. SYSTIMER APP supports following features:

  1. SYSTIMER APP creates the software timers with microseconds resolution using hardware SysTick timer as a reference.
  2. SYSTIMER APP can provides one shot and periodic software timer modes with user configurable time interval and supports maximum up to 16 software timers.
  3. Each software timer can be created with associated user callback registration using SYSTIMER_CreateTimer() API.
  4. The software timers callback is executed in the interrupt context.
  5. Software timer will start running by calling SYSTIMER_StartTimer() API.
  6. Software timer will be stopped by calling SYSTIMER_StopTimer() API.
  7. Each software timer created has unique ID obtained from SYSTIMER_CreateTimer(). This ID can be used in other API's provided by this APP to reference the software timer.
  8. Each software timer has a timer control block to describe the current status of the software timer. During run time, user can get the state of software timer using SYSTIMER_GetTimerState() API.
  9. Software timer can be reconfigured with new time interval using SYSTIMER_RestartTimer() API.
  10. All created software timers are managed through a timer list.
  11. SysTick exception controls the timer list and if any of the timer is expired corresponding call back function is called and which is registered through SYSTIMER_CreateTimer() API.
  12. Deletion of software timer after completion of usage using SYSTIMER_DeleteTimer() API.

Software timer mode of operation

  1. One shot:
    One shot software timer will cycle only once for the given time interval. Once the software timers period expires, the timer stops. The callback function is executed only once. The timer can be restarted manually by calling SYSTIMER_RestartTimer() API.
    Figure 1 : Software timer behaviour in One Shot mode.
  2. Periodic:
    Periodic software timer will cycle continuously for the given time interval. Once the period expires, the callback is executed and the timer is restarted automatically.
    Figure 2 : Software timer behaviour in Periodic mode.

Note: All Software timers are using hardware SysTick timer for basic count. Hardware timer and software timers may not be in synchronization when software timer is started or restarted. This may cause first period executed by software timer will be less than expected. To overcome this limitation one extra period (corresponding count) is added for all software timers. This extra count will lead to, first period of every software timer will become greater than or equal to expected period value via API SYSTIMER_CreateTimer(). While all other periods(if asked for periodic software timers) will generate as expected.

Finite State Machine (FSM) for SYSTIMER States

The Figure 3 illustrates the FSM for SYSTIMER States and gives an outline of the software timer functionality with respect to user request transaction through SYSTIMER APP APIs.

  • Creating a software timer using SYSTIMER_CreateTimer() API:
    All software timers are in UNINITIALIZED state after reset of device and creation of software timer by user using SYSTIMER_CreateTimer API changes the software timer states to STOPPED state.
  • Running a software timer using SYSTIMER_StartTimer() API:
    After creation of a software timer, user can start the software timer using SYSTIMER_StartTimer API and this changes the software timer states to RUNNING state.
  • Stopping a software timer using SYSTIMER_StopTimer() API:
    User can stop the software timer using SYSTIMER_StopTimer API and this changes the software timer states to STOPPED state.
  • Restarting a software timer using SYSTIMER_RestartTimer() API when software timer is in STOPPED state:
    User can restart the software timer (which is stopped previously) using SYSTIMER_RestartTimer API and this changes the software timer states to RUNNING state.
  • Restarting a software timer using SYSTIMER_RestartTimer() API when software timer is in RUNNING state:
    User can restart the software timer using SYSTIMER_RestartTimer API and this changes the software timer states to RUNNING state.
  • Deleting a software timer using SYSTIMER_DeleteTimer()() API when software timer is in RUNNING state:
    User can delete the software timer using SYSTIMER_DeleteTimer API and this changes the software timer states to UNINITIALIZED state.
  • Deleting a software timer using SYSTIMER_DeleteTimer()() API when software timer is in STOPPED state:
    User can delete the software timer (which is stopped previously) using SYSTIMER_DeleteTimer API and this changes the software timer states to UNINITIALIZED state.



Figure 3 : FSM for SYSTIMER States

Hardware and Software connectivity of SYSTIMER APP

Figure 4 : Hardware and Software connectivity of SYSTIMER APP.

Figure 4 shows the APP structure in DAVEā„¢. The APP configures the SysTick peripheral and clock using CLOCK_XMCxx APP.
The LLD layer provides abstraction for SysTick hardware modules.

Supported Devices
The APP supports below devices:

  1. XMC4800 / XMC4700 / XMC4300 Series
  2. XMC4500 Series
  3. XMC4400 Series
  4. XMC4200 / XMC4100 Series
  5. XMC1400 Series
  6. XMC1300 Series
  7. XMC1200 Series
  8. XMC1100 Series

References:

  1. XMC4800 / XMC4700 / XMC4300 Reference Manual
  2. XMC4500 Reference Manual
  3. XMC4400 Reference Manual
  4. XMC4200 / XMC4100 Reference Manual
  5. XMC1400 Reference Manual
  6. XMC1300 Reference Manual
  7. XMC1200 Reference Manual
  8. XMC1100 Reference Manual

Limitations
None