Introduction

Author: Catalin Visan, Microchip Technology Inc.

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

The Timer/Counter type A (TCA) is a 16-bit timer that is present in the tinyAVR® 0-series, tinyAVR® 1-series and megaAVR® 0-series. The main idea behind TCA is that a very flexible timer is needed in order to perform convoluted actions as well as the very basic functions of a simple timer. The flexibility comes from the multitude of features provided, such as the possibility of splitting the 16-bit timer in two completely independent 8-bit timers or the built-in Wave Generation modes. Another important characteristic is that TCA was devised to overcome common problems when using timers, such as the unpredictable behavior of the PWM signal when the duty cycle is changed while the timer is running. The TCA has double buffered registers that synchronize the updates of different registers, making the waveforms generated predictable in every single situation.

The purpose of this technical brief is to familiarize the reader with some of the operating modes of TCA, emphasizing this timer’s particularities and to provide initialization code snippets. For a deeper understanding of the functionality, please consult the data sheet. The structure of the document covers three specific use cases:

Note: The code examples were developed on ATmega4809 Xplained Pro (ATMEGA4809-XPRO).