25.3.3.2.4 8-Bit PWM Mode

The TCF can be configured to run in 8-bit PWM mode, using the register pairs in the lowest 16-bit Compare register (TCFn.CMP0 and TCFn.CMP1) as individual compare registers. The TCFn.CNT0 is used as the counter, the TCFn.CNT1 (PER) controls the waveform period (T), and CMP0/1 control the waveform's duty cycle. The figure below shows how the counter counts from BOTTOM to TOP and then restarts from BOTTOM. The waveform generator output is set at BOTTOM and cleared on the compare match between the TCFn.CNT0 and TCFn.CMPn registers.

Note: TCFn.CMPn = BOTTOM will generate a static low signal on WOn while TCFn.CMPn > TOP will produce a static high signal on WOn.
Figure 25-7. 8-Bit PWM Mode

The Period (TCFn.PER) register defines the PWM resolution. The minimum resolution is two bits (TCFn.PER = 0x0003), and the maximum resolution is eight bits (TCFn.PER = MAX).

The following equation calculates the exact resolution in bits for single-slope PWM (RPWM):

R PWM = log ( PER + 1 ) log ( 2 )

The single-slope PWM frequency (fPWM) depends on the period setting (TCFn.PER), the peripheral clock frequency fCLK_TCF and the TCF prescaler (the PRESC bit field in the TCFn.CTRLA register).

It is calculated by the following equation where N represents the prescaler divider used:

f PWM = f CLK_TCF N ( PER + 1 )