Configure a timer to input edge-timing mode with the following sequence:
- Ensure the timer is disabled (clear the GPT:CTL.TnEN bit) before making any changes.
- Write the GPTM Configuration register (GPT:CFG) with a value of 0x00000004.
- 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 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 GPT:IMR.CnMIM bit.
- Set the GPT:CTL.TnEN bit to enable the timer and start counting.
- Poll the GPT:RIS.CnMRIS bit, or wait for the interrupt to be generated (if enabled). In both cases, the status flags are cleared by writing a 1 to GPT:ICR.CnMCINT.
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.