2 Peripheral Overview: Timer/Counter Type F

The Timer/Counter type F capabilities include frequency and waveform generation. The TCF consists of a base counter and a control logic, which can be set in different modes, each providing unique functionality. A selectable clock source with optional prescaling clocks the base counter. The TCF features the following characteristics:

  • 24-Bit Timer/Counter
  • Operation Modes:
    • Frequency Generation
    • Numerically Controlled Oscillator (NCO)
      • Pulse-Frequency
      • Fixed Duty Cycle
    • 8-Bit Pulse-Width-Modulation (PWM)
  • 7-Bit Prescaler
  • Timer Overflow and Two Compare Match Events/Interrupts
  • Event Generation as Pulse or Waveform Output
  • Multiple Clock Sources
Figure 2-1. TCF Block Diagram

Depending on the operation mode, the peripheral’s registers functionality might be different. In the context of this technical brief, the focus is on the Frequency Waveform Generation mode.

In Frequency Waveform Generation mode, the TCFn.CMP register controls the period time. The corresponding waveform generator output is toggled on each compare match between the TCFn.CNT and TCFn.CMP registers. The following equation defines the waveform frequency:

fFRQ = fCLK_TCF / 2N(CMP+1)

where N represents the prescaler divider, and fCLK_TCF is the TCF clock frequency.

The OVF interrupt/event is generated on every overflow, while the CMP0 and CMP1 interrupts/events are generated on alternating overflows. When using the Event System, the OVF and CMPn events can be configured to trigger actions in other peripherals, without using the CPU.

Figure 2-2. TCF Frequency Waveform Generation

The application developed in the context of this technical brief uses the TCF and the Event System to trigger ADC conversions periodically, without software interaction. The TCF is configured in Frequency Waveform Generation mode, and the period of the generated signal is set to 20 ms, ensuring that a new ADC conversion or burst accumulation is triggered every 10 ms, depending on the operation mode.