Introduction

Author: Catalin Visan, Microchip Technology Inc.

The AVR® microcontrollers are equipped with powerful timers designed to cover a wide area of applications, from signal measurement to events synchronization and waveform generation.

The Timer/Counter type D (TCD) is a 12-bit timer available in tinyAVR® 1-series and AVR DA devices. The TCD is designed to cover the need for a fast timer with multiple waveform generation capabilities in common embedded applications, such as motor control or Switch mode power supplies. One of the key features of the TCD is that in addition to running from the main clock, it can be set up to run directly from the internal 20 MHz oscillator (OSC20M) or used with an external clock source. Moreover, it has multiple configurable Waveform Generation modes.

This document describes some of the TCD operating modes, emphasizing this timer’s particularities and providing initialization code snippets. For a deeper understanding of the functionality, refer to the tinyAVR® 1-series and AVR DA data sheet. The structure of the document comprises two specific use cases:
Note: For each of the use cases described in this document, there are two code examples: One bare metal developed on ATtiny817, and one generated with MPLAB® Code Configurator (MCC) developed on AVR128DA48.