Configure a timer to input edge-timing mode with the following sequence:
- Ensure the timer is disabled (the TAEN bit is cleared) before making any changes.
- Write the GPTM Configuration register (GPT:CFG) with a value of 0x0000 0004.
- In the GPTM Timer Mode register (GPT:TnMR), write the TnCM field to 0x1 and write the TnMR field to 0x3.
- Configure the type of events that the timer captures by writing the GPTM Control register (GPT:CTL) TnEVENT field.
- If a prescaler is to be used, write the prescale value to the GPTM Timer n Prescale register (GPT:TnPR).
- Load the timer start value into the GPTM Timer n Interval Load register (GPT:TnILR).
- If interrupts are required, set the GPTM Interrupt Mask register (GPT:IMR) CnMIM bit.
- Set the GPT:CTL TnEN register bit to enable the timer and start counting.
- Poll the GPT:RIS CnMRIS register bit, or wait for the interrupt to be generated (if enabled). In both cases, the status flags are cleared by writing a 1 to the GPTM Interrupt Clear register (GPT:ICR) CnMCINT bit.
In input-edge timing mode, the timer continues to run after an edge event is detected, but the timer interval can be changed at any time by writing the GPT:TnILR register. The change takes effect at the next cycle after the write.