Functional Description
1257
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
General-Purpose Timers
18.3.2 Timer Clock Source
The general purpose timer has the capability of being clocked by either the system clock or an alternate
clock source. By setting the ALTCLK bit in the GPTM Clock Configuration (GPTMCC) register, offset
0xFC8, software can selects an alternate clock source as programmed in the Alternate Clock
Configuration (ALTCLKCFG) register, offset 0x138 in the System Control Module. The alternate clock
source options available are PIOSC, RTCOSC, and LFIOSC. See
for additional information.
NOTE:
When the ALTCLK bit is set in the GPTMCC register to enable using the alternate clock
source, the synchronization imposes restrictions on the starting count value (down count),
terminal value (up count) and the match value. This restriction applies to all modes of
operation. Each event must be spaced by 4 Timer (ALTCLK) clock p 2 system clock
periods. If some events do not meet this requirement, then it is possible that the timer block
may need to be reset for correct functionality to be restored.
Example: ALTCLK = T
PIOSC
= 62.5 ns (16 MHz trimmed)
T
hclk
= 1 µs (1 MHz)
4 × 62.5 ns + 2 × 1 µs = 2.25 µs 2.25 µs / 62.5 ns = 36 or 0x23
The minimum values for the periodic or one-shot with a match interrupt enabled are:
GPTMTAMATCHR = 0x23 and GPTMTAILR = 0x46
18.3.3 Timer Modes
This section describes the operation of the various timer modes. When using Timer A and Timer B in
concatenated mode, only the Timer A control and status bits must be used; there is no need to use Timer
B control and status bits. The GPTM is placed into individual/split mode by writing a value of 0x4 to the
GPTM Configuration (GPTMCFG) register (see
). In the following sections, the variable
n
is
used in bit field and register names to imply either a Timer A function or a Timer B function. Throughout
this section, the time-out event in down-count mode is 0x0 and in up-count mode is the value in the GPTM
Timer n Interval Load (GPTMTnILR) and the optional GPTM Timer n Prescale (GPTMTnPR) registers,
with the exception of RTC mode.
18.3.3.1 One-Shot and Periodic Timer Mode
The selection of one-shot or periodic mode is determined by the value written to the TnMR field of the
GPTM Timer n Mode (GPTMTnMR) register (see
). The timer is configured to count up or
down using the TnCDIR bit in the GPTMTnMR register.
When software sets the TnEN bit in the GPTM Control (GPTMCTL) register (see
), the timer
begins counting up from 0x0 or down from its preloaded value. Alternatively, if the TnWOT bit is set in the
GPTMTnMR register, once the TnEN bit is set, the timer waits for a trigger to begin counting (see
).
lists the values that are loaded into the timer registers when the timer is
enabled.
Table 18-3. Counter Values When the Timer is Enabled in Periodic or One-Shot Modes
Register
Count Down Mode
Count Up Mode
GPTMTnR
GPTMTnILR
0x0
GPTMTnV
GPTMTnILR in concatenated mode; GPTMTnPR in combination with
GPTMTnILR in individual mode
0x0
GPTMTnPS
GPTMTnPR in individual mode; not available in concatenated mode
0x0 in individual mode; not available
in concatenated mode
When the timer is counting down and it reaches the time-out event (0x0), the timer reloads its start value
from the GPTMTnILR and the GPTMTnPR registers on the next cycle. When the timer is counting up and
it reaches the time-out event (the value in the GPTMTnILR and the optional GPTMTnPR registers), the
timer reloads with 0x0. If configured to be a one-shot timer, the timer stops counting and clears the TnEN
bit in the GPTMCTL register. If configured as a periodic timer, the timer starts counting again on the next
cycle.