1.28.7 ARM Cortex A Generic timer (GENERIC_TIMER)

The Generic Timer:

  1. Provides a system counter, that measures the passing of time in real-time

  2. Provides timers, that can assert a timer output signal after a period of time has passed.

  3. The timers can be used as a count-up or count-down timers

Using The Library

  • Generic Timer plib implements uses the counter view of the generic timer, wherein it is used as 64 bit up-counter

  • Timer is initialized using GENERIC_TIMER_Initialize() function which configures the timer registers with values based on the MHC GUI settings for this plib

  • Timer can be started using GENERIC_TIMER_Start() function and stopped using GENERIC_TIMER_Stop() APIs

  • Timer period can be set using GENERIC_TIMER_PeriodSet() function

  • If a callback is registered using GENERIC_TIMER_CallbackRegister() function, when the timer period expires (i.e. when the interrupt occurs), the callback function will be executed

Library Interface

ARM Cortex A Generic timer peripheral library provides the following interfaces:

Functions

Name Description
GENERIC_TIMER_Initialize Initialize Generic Timer registers per user config
GENERIC_TIMER_CounterValueGet Returns 64 bit counter value
GENERIC_TIMER_CounterFrequencyGet Returns counter frequency
GENERIC_TIMER_Start Start the Generic timer
GENERIC_TIMER_Stop Stop Generic timer
GENERIC_TIMER_PeriodSet Set the timer period value
GENERIC_TIMER_PeriodGet Get the timer period value
GENERIC_TIMER_DelayMs Delays processing for x milliseconds
GENERIC_TIMER_DelayUs Delays processing for x microseconds
GENERIC_TIMER_CallbackRegister Register callback for generic timer interrupt

Data types and constants

Name Type Description
GENERIC_TIMER_CALLBACK Typedef Generic Timer Interrupt Callback Function definition