6.
If interrupts are required, set the
CnMIM
bit in the
GPTM Interrupt Mask (GPTMIMR)
register.
7.
Set the
TnEN
bit in the
GPTMCTL
register to enable the timer and begin waiting for edge events.
8.
Poll the
CnMRIS
bit in the
GPTMRIS
register or wait for the interrupt to be generated (if enabled).
In both cases, the status flags are cleared by writing a 1 to the
CnMCINT
bit of the
GPTM
Interrupt Clear (GPTMICR)
register.
When counting down in Input Edge-Count Mode, the timer stops after the programmed number of
edge events has been detected. To re-enable the timer, ensure that the
TnEN
bit is cleared and
repeat steps 4 through 8.
13.4.4
Input Edge Time Mode
A timer is configured to Input Edge Time mode by the following sequence:
1.
Ensure the timer is disabled (the
TnEN
bit is cleared) before making any changes.
2.
Write the
GPTM Configuration (GPTMCFG)
register with a value of 0x0000.0004.
3.
In the
GPTM Timer Mode (GPTMTnMR)
register, write the
TnCMR
field to 0x1 and the
TnMR
field to 0x3 and select a count direction by programming the
TnCDIR
bit.
4.
Configure the type of event that the timer captures by writing the
TnEVENT
field of the
GPTM
Control (GPTMCTL)
register.
5.
If a prescaler is to be used, write the prescale value to the
GPTM Timer n Prescale Register
(GPTMTnPR)
.
6.
Load the timer start value into the
GPTM Timer n Interval Load (GPTMTnILR)
register.
7.
If interrupts are required, set the
CnEIM
bit in the
GPTM Interrupt Mask (GPTMIMR)
register.
8.
Set the
TnEN
bit in the
GPTM Control (GPTMCTL)
register to enable the timer and start counting.
9.
Poll the
CnERIS
bit in the
GPTMRIS
register or wait for the interrupt to be generated (if enabled).
In both cases, the status flags are cleared by writing a 1 to the
CnECINT
bit of the
GPTM
Interrupt Clear (GPTMICR)
register. The time at which the event happened can be obtained
by reading the
GPTM Timer n (GPTMTnR)
register.
In Input Edge Timing mode, the timer continues running after an edge event has been detected,
but the timer interval can be changed at any time by writing the
GPTMTnILR
register and clearing
the
TnILD
bit in the
GPTMTnMR
register. The change takes effect at the next cycle after the write.
13.4.5
PWM Mode
A timer is configured to PWM mode using the following sequence:
1.
Ensure the timer is disabled (the
TnEN
bit is cleared) before making any changes.
2.
Write the
GPTM Configuration (GPTMCFG)
register with a value of 0x0000.0004.
3.
In the
GPTM Timer Mode (GPTMTnMR)
register, set the
TnAMS
bit to 0x1, the
TnCMR
bit to
0x0, and the
TnMR
field to 0x2.
973
June 18, 2014
Texas Instruments-Production Data
Tiva
™
TM4C1294NCPDT Microcontroller