Tiva Driver Lib
Functions
Timer_api

Functions

void TimerEnable (uint32_t ui32Base, uint32_t ui32Timer)
 
void TimerDisable (uint32_t ui32Base, uint32_t ui32Timer)
 
void TimerConfigure (uint32_t ui32Base, uint32_t ui32Config)
 
void TimerControlLevel (uint32_t ui32Base, uint32_t ui32Timer, bool bInvert)
 
void TimerControlTrigger (uint32_t ui32Base, uint32_t ui32Timer, bool bEnable)
 
void TimerControlEvent (uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Event)
 
void TimerControlStall (uint32_t ui32Base, uint32_t ui32Timer, bool bStall)
 
void TimerControlWaitOnTrigger (uint32_t ui32Base, uint32_t ui32Timer, bool bWait)
 
void TimerRTCEnable (uint32_t ui32Base)
 
void TimerRTCDisable (uint32_t ui32Base)
 
void TimerPrescaleSet (uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
 
uint32_t TimerPrescaleGet (uint32_t ui32Base, uint32_t ui32Timer)
 
void TimerPrescaleMatchSet (uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
 
uint32_t TimerPrescaleMatchGet (uint32_t ui32Base, uint32_t ui32Timer)
 
void TimerLoadSet (uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
 
uint32_t TimerLoadGet (uint32_t ui32Base, uint32_t ui32Timer)
 
void TimerLoadSet64 (uint32_t ui32Base, uint64_t ui64Value)
 
uint64_t TimerLoadGet64 (uint32_t ui32Base)
 
uint32_t TimerValueGet (uint32_t ui32Base, uint32_t ui32Timer)
 
uint64_t TimerValueGet64 (uint32_t ui32Base)
 
void TimerMatchSet (uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
 
uint32_t TimerMatchGet (uint32_t ui32Base, uint32_t ui32Timer)
 
void TimerMatchSet64 (uint32_t ui32Base, uint64_t ui64Value)
 
uint64_t TimerMatchGet64 (uint32_t ui32Base)
 
void TimerIntRegister (uint32_t ui32Base, uint32_t ui32Timer, void(*pfnHandler)(void))
 
void TimerIntUnregister (uint32_t ui32Base, uint32_t ui32Timer)
 
void TimerIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void TimerIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
uint32_t TimerIntStatus (uint32_t ui32Base, bool bMasked)
 
void TimerIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void TimerSynchronize (uint32_t ui32Base, uint32_t ui32Timers)
 

Detailed Description

Function Documentation

void TimerConfigure ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the timer(s).

Parameters
ui32Baseis the base address of the timer module.
ui32Configis the configuration for the timer.

This function configures the operating mode of the timer(s). The timer module is disabled before being configured and is left in the disabled state. The timer can be configured to be a single full-width timer by using the TIMER_CFG_* values or a pair of half-width timers using the TIMER_CFG_A_* and TIMER_CFG_B_* values passed in the ui32Config parameter.

The configuration is specified in ui32Config as one of the following values:

  • TIMER_CFG_ONE_SHOT - Full-width one-shot timer
  • TIMER_CFG_ONE_SHOT_UP - Full-width one-shot timer that counts up instead of down (not available on all parts)
  • TIMER_CFG_PERIODIC - Full-width periodic timer
  • TIMER_CFG_PERIODIC_UP - Full-width periodic timer that counts up instead of down (not available on all parts)
  • TIMER_CFG_RTC - Full-width real time clock timer
  • TIMER_CFG_SPLIT_PAIR - Two half-width timers

When configured for a pair of half-width timers, each timer is separately configured. The first timer is configured by setting ui32Config to the result of a logical OR operation between one of the following values and ui32Config:

  • TIMER_CFG_A_ONE_SHOT - Half-width one-shot timer
  • TIMER_CFG_A_ONE_SHOT_UP - Half-width one-shot timer that counts up instead of down (not available on all parts)
  • TIMER_CFG_A_PERIODIC - Half-width periodic timer
  • TIMER_CFG_A_PERIODIC_UP - Half-width periodic timer that counts up instead of down (not available on all parts)
  • TIMER_CFG_A_CAP_COUNT - Half-width edge count capture
  • TIMER_CFG_A_CAP_COUNT_UP - Half-width edge count capture that counts up instead of down (not available on all parts)
  • TIMER_CFG_A_CAP_TIME - Half-width edge time capture
  • TIMER_CFG_A_CAP_TIME_UP - Half-width edge time capture that counts up instead of down (not available on all parts)
  • TIMER_CFG_A_PWM - Half-width PWM output

Similarly, the second timer is configured by setting ui32Config to the result of a logical OR operation between one of the corresponding TIMER_CFG_B_* values and ui32Config.

Returns
None.
void TimerControlEvent ( uint32_t  ui32Base,
uint32_t  ui32Timer,
uint32_t  ui32Event 
)

Controls the event type.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to be adjusted; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
ui32Eventspecifies the type of event; must be one of TIMER_EVENT_POS_EDGE, TIMER_EVENT_NEG_EDGE, or TIMER_EVENT_BOTH_EDGES.

This function configures the signal edge(s) that triggers the timer when in capture mode.

Returns
None.
void TimerControlLevel ( uint32_t  ui32Base,
uint32_t  ui32Timer,
bool  bInvert 
)

Controls the output level.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
bInvertspecifies the output level.

This function configures the PWM output level for the specified timer. If the bInvert parameter is true, then the timer's output is made active low; otherwise, it is made active high.

Returns
None.
void TimerControlStall ( uint32_t  ui32Base,
uint32_t  ui32Timer,
bool  bStall 
)

Controls the stall handling.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to be adjusted; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
bStallspecifies the response to a stall signal.

This function controls the stall response for the specified timer. If the bStall parameter is true, then the timer stops counting if the processor enters debug mode; otherwise the timer keeps running while in debug mode.

Returns
None.
void TimerControlTrigger ( uint32_t  ui32Base,
uint32_t  ui32Timer,
bool  bEnable 
)

Enables or disables the ADC trigger output.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
bEnablespecifies the desired ADC trigger state.

This function controls the ADC trigger output for the specified timer. If the bEnable parameter is true, then the timer's ADC output trigger is enabled; otherwise it is disabled.

Returns
None.
void TimerControlWaitOnTrigger ( uint32_t  ui32Base,
uint32_t  ui32Timer,
bool  bWait 
)

Controls the wait on trigger handling.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to be adjusted; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
bWaitspecifies if the timer should wait for a trigger input.

This function controls whether or not a timer waits for a trigger input to start counting. When enabled, the previous timer in the trigger chain must count to its timeout in order for this timer to start counting. Refer to the part's data sheet for a description of the trigger chain.

Note
This functionality is not available on all parts. This function should not be used for Timer 0A or Wide Timer 0A.
Returns
None.
void TimerDisable ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Disables the timer(s).

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to disable; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.

This function disables operation of the timer module.

Returns
None.
void TimerEnable ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Enables the timer(s).

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to enable; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.

This function enables operation of the timer module. The timer must be configured before it is enabled.

Returns
None.
void TimerIntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears timer interrupt sources.

Parameters
ui32Baseis the base address of the timer module.
ui32IntFlagsis a bit mask of the interrupt sources to be cleared.

The specified timer interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to TimerIntEnable().

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns
None.
void TimerIntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables individual timer interrupt sources.

Parameters
ui32Baseis the base address of the timer module.
ui32IntFlagsis the bit mask of the interrupt sources to be disabled.

This function disables the indicated timer interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to TimerIntEnable().

Returns
None.
void TimerIntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables individual timer interrupt sources.

Parameters
ui32Baseis the base address of the timer module.
ui32IntFlagsis the bit mask of the interrupt sources to be enabled.

This function enables the indicated timer interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The ui32IntFlags parameter must be the logical OR of any combination of the following:

  • TIMER_CAPB_EVENT - Capture B event interrupt
  • TIMER_CAPB_MATCH - Capture B match interrupt
  • TIMER_TIMB_TIMEOUT - Timer B timeout interrupt
  • TIMER_RTC_MATCH - RTC interrupt mask
  • TIMER_CAPA_EVENT - Capture A event interrupt
  • TIMER_CAPA_MATCH - Capture A match interrupt
  • TIMER_TIMA_TIMEOUT - Timer A timeout interrupt
Returns
None.
void TimerIntRegister ( uint32_t  ui32Base,
uint32_t  ui32Timer,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for the timer interrupt.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s); must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
pfnHandleris a pointer to the function to be called when the timer interrupt occurs.

This function registers the handler to be called when a timer interrupt occurs. In addition, this function enables the global interrupt in the interrupt controller; specific timer interrupts must be enabled via TimerIntEnable(). It is the interrupt handler's responsibility to clear the interrupt source via TimerIntClear().

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.
uint32_t TimerIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current interrupt status.

Parameters
ui32Baseis the base address of the timer module.
bMaskedis false if the raw interrupt status is required and true if the masked interrupt status is required.

This function returns the interrupt status for the timer module. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Returns
The current interrupt status, enumerated as a bit field of values described in TimerIntEnable().
void TimerIntUnregister ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Unregisters an interrupt handler for the timer interrupt.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s); must be one of TIMER_A, TIMER_B, or TIMER_BOTH.

This function unregisters the handler to be called when a timer interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler is no longer called.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.
uint32_t TimerLoadGet ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Gets the timer load value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer; must be one of TIMER_A or TIMER_B. Only TIMER_A should be used when the timer is configured for full-width operation.

This function gets the currently programmed interval load value for the specified timer.

Note
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use TimerLoadGet64() for full-width modes of 32/64-bit timers.
Returns
Returns the load value for the timer.
uint64_t TimerLoadGet64 ( uint32_t  ui32Base)

Gets the timer load value for a 64-bit timer.

Parameters
ui32Baseis the base address of the timer module.

This function gets the currently programmed interval load value for the specified 64-bit timer.

Returns
Returns the load value for the timer.
void TimerLoadSet ( uint32_t  ui32Base,
uint32_t  ui32Timer,
uint32_t  ui32Value 
)

Sets the timer load value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH. Only TIMER_A should be used when the timer is configured for full-width operation.
ui32Valueis the load value.

This function configures the timer load value; if the timer is running then the value is immediately loaded into the timer.

Note
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use TimerLoadSet64() for full-width modes of 32/64-bit timers.
Returns
None.
void TimerLoadSet64 ( uint32_t  ui32Base,
uint64_t  ui64Value 
)

Sets the timer load value for a 64-bit timer.

Parameters
ui32Baseis the base address of the timer module.
ui64Valueis the load value.

This function configures the timer load value for a 64-bit timer; if the timer is running, then the value is immediately loaded into the timer.

Returns
None.
uint32_t TimerMatchGet ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Gets the timer match value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer; must be one of TIMER_A or TIMER_B. Only TIMER_A should be used when the timer is configured for full-width operation.

This function gets the match value for the specified timer.

Note
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use TimerMatchGet64() for full-width modes of 32/64-bit timers.
Returns
Returns the match value for the timer.
uint64_t TimerMatchGet64 ( uint32_t  ui32Base)

Gets the timer match value for a 64-bit timer.

Parameters
ui32Baseis the base address of the timer module.

This function gets the match value for the specified timer.

Returns
Returns the match value for the timer.
void TimerMatchSet ( uint32_t  ui32Base,
uint32_t  ui32Timer,
uint32_t  ui32Value 
)

Sets the timer match value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH. Only TIMER_A should be used when the timer is configured for full-width operation.
ui32Valueis the match value.

This function configures the match value for a timer. This value is used in capture count mode to determine when to interrupt the processor and in PWM mode to determine the duty cycle of the output signal. On some Tiva devices, match interrupts can also be generated in periodic and one-shot modes.

Note
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use TimerMatchSet64() for full-width modes of 32/64-bit timers.
Returns
None.
void TimerMatchSet64 ( uint32_t  ui32Base,
uint64_t  ui64Value 
)

Sets the timer match value for a 64-bit timer.

Parameters
ui32Baseis the base address of the timer module.
ui64Valueis the match value.

This function configures the match value for a timer. This value is used in capture count mode to determine when to interrupt the processor and in PWM mode to determine the duty cycle of the output signal.

Returns
None.
uint32_t TimerPrescaleGet ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Get the timer prescale value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer; must be one of TIMER_A or TIMER_B.

This function gets the value of the input clock prescaler. The prescaler is only operational when in half-width mode and is used to extend the range of the half-width timer modes. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits.

Note
The availability of the prescaler varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns
The value of the timer prescaler.
uint32_t TimerPrescaleMatchGet ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Get the timer prescale match value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer; must be one of TIMER_A or TIMER_B.

This function gets the value of the input clock prescaler match value. When in a half-width mode that uses the counter match and prescaler, the prescale match effectively extends the range of the match. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits.

Note
The availability of the prescaler match varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns
The value of the timer prescale match.
void TimerPrescaleMatchSet ( uint32_t  ui32Base,
uint32_t  ui32Timer,
uint32_t  ui32Value 
)

Set the timer prescale match value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
ui32Valueis the timer prescale match value which must be between 0 and 255 (inclusive) for 16/32-bit timers and between 0 and 65535 (inclusive) for 32/64-bit timers.

This function configures the value of the input clock prescaler match value. When in a half-width mode that uses the counter match and the prescaler, the prescale match effectively extends the range of the match. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits.

Note
The availability of the prescaler match varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns
None.
void TimerPrescaleSet ( uint32_t  ui32Base,
uint32_t  ui32Timer,
uint32_t  ui32Value 
)

Set the timer prescale value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer(s) to adjust; must be one of TIMER_A, TIMER_B, or TIMER_BOTH.
ui32Valueis the timer prescale value which must be between 0 and 255 (inclusive) for 16/32-bit timers and between 0 and 65535 (inclusive) for 32/64-bit timers.

This function configures the value of the input clock prescaler. The prescaler is only operational when in half-width mode and is used to extend the range of the half-width timer modes. The prescaler provides the least significant bits when counting down in periodic and one-shot modes; in all other modes, the prescaler provides the most significant bits.

Note
The availability of the prescaler varies with the Tiva part and timer mode in use. Please consult the datasheet for the part you are using to determine whether this support is available.
Returns
None.
void TimerRTCDisable ( uint32_t  ui32Base)

Disable RTC counting.

Parameters
ui32Baseis the base address of the timer module.

This function causes the timer to stop counting when in RTC mode.

Returns
None.
void TimerRTCEnable ( uint32_t  ui32Base)

Enable RTC counting.

Parameters
ui32Baseis the base address of the timer module.

This function causes the timer to start counting when in RTC mode. If not configured for RTC mode, this function does nothing.

Returns
None.
void TimerSynchronize ( uint32_t  ui32Base,
uint32_t  ui32Timers 
)

Synchronizes the counters in a set of timers.

Parameters
ui32Baseis the base address of the timer module. This parameter must be the base address of Timer0 (in other words, TIMER0_BASE).
ui32Timersis the set of timers to synchronize.

This function synchronizes the counters in a specified set of timers. When a timer is running in half-width mode, each half can be included or excluded in the synchronization event. When a timer is running in full-width mode, only the A timer can be synchronized (specifying the B timer has no effect).

The ui32Timers parameter is the logical OR of any of the following defines:

  • TIMER_0A_SYNC
  • TIMER_0B_SYNC
  • TIMER_1A_SYNC
  • TIMER_1B_SYNC
  • TIMER_2A_SYNC
  • TIMER_2B_SYNC
  • TIMER_3A_SYNC
  • TIMER_3B_SYNC
  • TIMER_4A_SYNC
  • TIMER_4B_SYNC
  • TIMER_5A_SYNC
  • TIMER_5B_SYNC
  • WTIMER_0A_SYNC
  • WTIMER_0B_SYNC
  • WTIMER_1A_SYNC
  • WTIMER_1B_SYNC
  • WTIMER_2A_SYNC
  • WTIMER_2B_SYNC
  • WTIMER_3A_SYNC
  • WTIMER_3B_SYNC
  • WTIMER_4A_SYNC
  • WTIMER_4B_SYNC
  • WTIMER_5A_SYNC
  • WTIMER_5B_SYNC
Note
This functionality is not available on all parts.
Returns
None.
uint32_t TimerValueGet ( uint32_t  ui32Base,
uint32_t  ui32Timer 
)

Gets the current timer value.

Parameters
ui32Baseis the base address of the timer module.
ui32Timerspecifies the timer; must be one of TIMER_A or TIMER_B. Only TIMER_A should be used when the timer is configured for full-width operation.

This function reads the current value of the specified timer.

Note
This function can be used for both full- and half-width modes of 16/32-bit timers and for half-width modes of 32/64-bit timers. Use TimerValueGet64() for full-width modes of 32/64-bit timers.
Returns
Returns the current value of the timer.
uint64_t TimerValueGet64 ( uint32_t  ui32Base)

Gets the current 64-bit timer value.

Parameters
ui32Baseis the base address of the timer module.

This function reads the current value of the specified timer.

Returns
Returns the current value of the timer.