23.3.4.4.2 Frequency Waveform Generation (FRQ)

In Frequency Generation mode, the TCEn.CMP0 register controls the period time (T), instead of the Period (TCEn.PER) register. The corresponding waveform generator output is toggled on each compare match between the TCEn.CNT and TCEn.CMPn registers.

Figure 23-8. Frequency Waveform Generation

The following equation defines the waveform frequency (fFRQ):

fFRQ=fCLK_PER2N(CMP0+1)

where N represents the prescaler divider used (see the CLKSEL bit field in the TCEn.CTRLA register), and fCLK_PER is the peripheral clock frequency.

The maximum frequency of the waveform generated is half of the peripheral clock frequency (fCLK_PER/2) when TCEn.CMP0 is written to 0x0000, and no prescaling is used (N = 1, CLKSEL = 0x0 in TCEn.CTRLA).

Use the TCEn.CMP1 and TCEn.CMP2 registers to get additional waveform outputs WOn. The waveforms WOn can either be identical or offset to WO0. The offset can be influenced by TCEn.CMPn, TCEn.CNT and the count direction. Use the equations shown in the table below to calculate the offset in seconds (Toffset). The equations are only valid when CMPn < CMP0.

Table 23-3. Offset Equation Overview
EquationCount DirectionCMPn vs. CNT StateOffset
Toffset=(CMP0CMPnCMP0+1)(T2)UPCMPn ≥ CNTWOn leading WO0
DOWNCMP0 ≤ CNT WOn trailing WO0
CMP0 > CNT and CMPn > CNTWOn trailing WO0
Toffset=(CMPn+1CMP0+1)(T2)UP CMPn < CNTWOn trailing WO0
DOWNCMPn ≤ CNT WOn leading WO0

The figure below shows the leading and trailing offset for WOn, where both equations can be used. The correct equation is determined by count direction and the state of CMPn vs. CNT when the timer is enabled or the CMPn is changed.

Figure 23-9. Offset When Counting Up

The figure below shows how the waveform can be inverted by changing the CMPn during run-time.

Figure 23-10. Inverting Waveform Output