The value written to CTL.MODE[0:2] determines the counter mode as follows:
- UP_ONCE: The timer counts from 0 to the selected target. The timer then becomes disabled.
- UP_PER: The timer counts from 0 to the selected target, repeatedly.
- UPDWN_PER: The timer counts from 0 to the selected target and decrements back to 0, repeatedly.
- QDEC: The timer functions as a quadrature decoder. IOC input 0, IOC input 1, and IOC input 2 are used respectively as PHA, PHB, and IDX inputs. IDX can be turned off by setting CH2CCFG.EDGE = NONE.
- SYNC_UP_ONCE: Same as UP_ONCE but the timer synchronizes to another timer. Choose which timer in STARTCFG.
- SYNC_UP_PER: Same as UP_PER but the timer synchronizes to another timer. Choose which timer in STARTCFG.
- SYNC_UPDWN_PER: Same as SYNC_UPDWN_PER but the timer synchronizes to another timer. Choose which timer in STARTCFG.
Note: While the counter can be written, the intent is only to support the setting of an initial position in QDEC mode. The ability to write the counter in other modes while the timer is running is possible, but the resulting behavior is unpredictable.