GPTMTnR=Y
Input Signal
Time
Count
GPTMTnR=X
GPTMTnR=Z
Z
X
Y
0xFFFF
Functional Description
1262
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
General-Purpose Timers
After an event has been captured, the timer does not stop counting. It continues to count until the TnEN
bit is cleared. When the timer reaches the time-out value, it is reloaded with 0x0 in up-count mode and the
value from the GPTMTnILR and GPTMTnPR registers in down-count mode.
shows how input edge timing mode works. In the diagram, it is assumed that the start value of
the timer is the default value of 0xFFFF, and the timer is configured to capture rising edge events.
Each time a rising edge event is detected, the current count value is loaded into the GPTMTnR and
GPTMTnPS registers, and held there until another rising edge is detected (at which point the new count
value is loaded into the GPTMTnR and GPTMTnPS registers).
Figure 18-3. 16-Bit Input Edge-Time Mode Example
NOTE:
When operating in Edge-time mode, the counter uses a modulo 2
24
count if the prescaler is
enabled, or 2
16
if not. If there is a possibility the edge could take longer than the count, then
another timer configured in periodic-timer mode can be implemented to ensure detection of
the missed edge. The periodic timer should be configured in such a way that:
•
The periodic timer cycles at the same rate as the edge-time timer
•
The periodic timer interrupt has a higher interrupt priority than the edge-time
time-out interrupt.
•
If the periodic timer interrupt service routine is entered, software must check if
an edge-time interrupt is pending and if it is, the value of the counter must be
subtracted by 1 before being used to calculate the snapshot time of the event.
18.3.3.5 PWM Mode
The GPTM supports a simple PWM generation mode. In PWM mode, the timer is configured as a 24-bit
down counter with a start value (and thus period) defined by the GPTMTnILR and GPTMTnPR registers.
In this mode, the PWM frequency and period are synchronous events and therefore guaranteed to be
glitch-free. PWM mode is enabled with the GPTMTnMR register by setting the TnAMS bit to 0x1, the
TnCMR bit to 0x0, and the TnMR field to 0x2.
lists the values that are loaded into the timer
registers when the timer is enabled.
Table 18-8. Counter Values When the Timer is Enabled
in PWM Mode
Register
Count Down Mode
Count Up Mode
GPTMTnR
GPTMTnILR
Not available
GPTMTnV
GPTMTnILR
Not available