# Single-Slope PWM Generation

For single-slope Pulse-Width Modulation (PWM) generation, the TCAn.PER register controls the period (T), while the TCAn.CMPn register values control the duty cycles of the generated waveforms. 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 TCAn.CNT and TCAn.CMPn registers.

CMPn = BOTTOM will produce a static low signal on WOn, while CMPn > TOP will produce a static high signal on WOn.

Figure 1. Single-Slope Pulse-Width Modulation
Notes:
1. 1.The representation in the figure above is valid when CMPn is updated using CMPnBUF.
2. 2.For single-slope Pulse-Width Modulation (PWM) generation, the counter counting from TOP to BOTTOM is not supported.

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

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

RPWM_SS=log(PER+1)log(2)

The single-slope PWM frequency (fPWM_SS) depends on the period setting (TCAn.PER), the peripheral clock frequency fCLK_PER, and the TCA prescaler (the CLKSEL bit field in the TCAn.CTRLA register). It is calculated by the following equation, where N represents the prescaler divider used:

fPWM_SS=fCLK_PERN(PER+1)