20.3.3.4.3 Single-Slope PWM Generation
For single-slope Pulse-Width Modulation (PWM) generation, the period (T) is controlled by the TCAn.PER register, while the values of the TCAn.CMPn registers 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.
- The representation in the figure above is valid when CMPn is updated using CMPnBUF.
- For single-slope Pulse-Width Modulation (PWM) generation, the counter counting from TOP to BOTTOM is not supported.
The TCAn.PER register defines the PWM resolution. The minimum resolution is 2 bits (TCAn.PER = 0x0002), and the maximum resolution is 16 bits (TCAn.PER = MAX-1).
The following equation calculates the exact resolution in bits for single-slope PWM (RPWM_SS):
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: