23.2 Overview
The flexible 16-Bit PWM Timer/Counter type E (TCE) provides accurate program execution timing, frequency and waveform generation, and command execution.
The Timer/Counter consists of a base counter and compare channels. The base counter can be used to count clock cycles or events or let events control how it counts clock cycles. The counting direction and period setting control is used for accurate timing. The compare channels can be used with the base counter for compare match control, frequency generation, and pulse width waveform modulation.
Depending on the mode of operation, the counter is cleared, reloaded, incremented, or decremented at each timer/counter clock or event input.
A timer/counter can be clocked and timed from the peripheral clock, with optional prescaling, or from the Event System. The Event System can also be used for direction control or synchronize operations.
The counter register (TCEn.CNT), period registers with buffer (TCEn.PER and TCEn.PERBUF), and compare registers with buffers (TCEn.CMPn and TCEn.CMPBUFn) are 16-bit registers. All buffer registers have a buffer valid (BV) flag that indicates when the buffer contains a new value.
During normal operation, the counter value is compared continuously to zero and the period (PER) value to determine whether the counter has reached TOP or BOTTOM.
The counter includes a high-resolution option that can increase the duty cycle resolution by up to eight times the input clock.
The counter value is also compared to the TCEn.CMPn registers. These comparisons can be used to generate interrupt requests. The Waveform Generator modes use these comparisons to set the waveform period or pulse width.
To control the counter, use a prescaled peripheral clock and events from the Event System.