Introduction

Author: Teodor Lina Microchip Technology Inc.

The AVR® EB family of microcontrollers uses powerful timers structured to cover several applications, from signal measurement to event synchronization and waveform generation. The Timer/Counter type E (TCE) is a 16-bit Timer/Counter peripheral that can generate up to four Pulse-Width Modulation (PWM) signals and has multiple waveform generation modes. The Waveform Extension (WEX) is a waveform extension peripheral that enhances the capabilities of the TCE. The TCE and WEX peripherals can generate up to eight PWM signals.

The capabilities of the 16-bit PWM TCE include accurate program execution timing, command execution, frequency and waveform generation. The TCE consists of a base counter and a set of compare channels. The base counter is used to count clock cycles and events or enable the events to count the clock cycles. The compare channels can be used with the base counter to perform a compare match control, frequency generation and pulse-width modulation.

The WEX enhances the capabilities of the 16-bit PWM TCE. This peripheral can produce complementary waveform output signals, generate a dead time between these signals, generate and manage Fault events, and override port outputs. The key feature is that the WEX overcomes common problems when using timers for applications such as motor control. With the dead time added, the signals are not overlapping, avoiding shoot-throughs caused by the transistor’s switching. WEX can also make Fault conditions, driving all the signals into a user-defined state, a significant feature in applications where safety is crucial. Every functionality from WEX occurs inside the hardware, making the waveforms generated predictable in every situation.

This technical brief familiarizes the reader with several operating modes for the TCE and WEX, emphasizing the timer’s particularities. For a better understanding of the functionality, refer to the data sheet.

The structure of the document covers three specific use cases:

Note: For each use case described in this document, there are two code examples: One bare metal developed on AVR16EB32 and one generated with MPLAB® Code Configurator (MCC) developed on AVR16EB32.

Bare metal code examples for AVR16EB32 with the same functionality as the ones described in this technical brief can be found here:

MCC Melody generated code examples for AVR16EB32 with the same functionality as the ones described in this technical brief can be found here: