18.4.4 Input Edge Time Mode
A timer is configured to Input Edge Time mode by the following sequence:
- Ensure the timer is disabled (the TnEN bit is cleared) before making any changes.
- Write the GPTM Configuration (GPTMCFG) register with a value of 0x0000.0004.
- 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.
- Configure the type of event that the timer captures by writing the TnEVENT field of the GPTM Control (GPTMCTL) register.
- If a prescaler is to be used, write the prescale value to the GPTM Timer n Prescale Register (GPTMTnPR).
- Load the timer start value into the GPTM Timer n Interval Load (GPTMTnILR) register.
- If interrupts are required, set the CnEIM bit in the GPTM Interrupt Mask (GPTMIMR) register.
- Set the TnEN bit in the GPTM Control (GPTMCTL) register to enable the timer and start counting.
- 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.