English
Language : 

LM3S5R36_13 Datasheet, PDF (463/1063 Pages) Texas Instruments – LM3S5R36 Microcontroller
NRND: Not recommended for new designs.
Stellaris® LM3S5R36 Microcontroller
10.3.2.1
One-Shot/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 page 476). 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 page 480), 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 the section called “Wait-for-Trigger Mode” on page 464). Table 10-4 on page 463 shows
the values that are loaded into the timer registers when the timer is enabled.
Table 10-4. Counter Values When the Timer is Enabled in Periodic or One-Shot Modes
Register
TnR
TnV
Count Down Mode
GPTMTnILR
GPTMTnILR
Count Up Mode
0x0
0x0
When the timer is counting down and it reaches the timeout 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 timeout 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.
In periodic, snap-shot mode (TnMR field is 0x2 and the TnSNAPS bit is set in the GPTMTnMR
register), the value of the timer at the time-out event is loaded into the GPTMTnR register. The
free-running counter value is shown in the GPTMTnV register. In this manner, software can determine
the time elapsed from the interrupt assertion to the ISR entry by examining the snapshot values
and the current value of the free-running timer. Snapshot mode is not available when the timer is
configured in one-shot mode.
In addition to reloading the count value, the GPTM generates interrupts and triggers when it reaches
the time-out event. The GPTM sets the TnTORIS bit in the GPTM Raw Interrupt Status (GPTMRIS)
register (see page 485), and holds it until it is cleared by writing the GPTM Interrupt Clear (GPTMICR)
register (see page 491). If the time-out interrupt is enabled in the GPTM Interrupt Mask (GPTMIMR)
register (see page 483), the GPTM also sets the TnTOMIS bit in the GPTM Masked Interrupt Status
(GPTMMIS) register (see page 488). By setting the TnMIE bit in the GPTMTnMR register, an interrupt
condition can also be generated when the Timer value equals the value loaded into the GPTM Timer
n Match (GPTMTnMATCHR) and GPTM Timer n Prescale Match (GPTMTnPMR) registers. This
interrupt has the same status, masking, and clearing functions as the time-out interrupt, but uses
the match interrupt bits instead (for example, the raw interrupt status is monitored via TnMRIS bit
in the GPTM Raw Interrupt Status (GPTMRIS) register). Note that the interrupt status bits are not
updated by the hardware unless the TnMIE bit in the GPTMTnMR register is set, which is different
than the behavior for the time-out interrupt. The ADC trigger is enabled by setting the TnOTE bit in
GPTMCTL. The μDMA trigger is enabled by configuring and enabling the appropriate μDMA channel.
See “Channel Configuration” on page 354.
If software updates the GPTMTnILR register while the counter is counting down, the counter loads
the new value on the next clock cycle and continues counting from the new value. If software updates
the GPTMTnILR register while the counter is counting up, the timeout event is changed on the next
cycle to the new value. If software updates the GPTM Timer n Value (GPTMTnV) register while
the counter is counting up or down, the counter loads the new value on the next clock cycle and
continues counting from the new value..
October 06, 2012
463
Texas Instruments-Production Data