Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TC Example 3 for xplain Documentation

Introduction

This simple example shows how to use the Timer Counter (TC) for generation of pulsed width modulation signals.

Main files:

  • tc.c timer/counter driver implementation
  • tc.h timer/counter driver definitions
  • tc_example3.c: tc driver example application
  • conf_tc.h: configuration of the tc driver

tc driver API

The tc driver API can be found here.

Device Info

All AVR XMEGA devices with tc and awex modules can be used.

Description of the example

The example will configure the Timer E0 (TCE0) in waveform generator mode. AWex is used to output PWM signals from Compare modules CCA and CCB. These complementary signals are output on Port E0 and E1. Deadtimes are inserted. This example is dimming the duty-cycle of the two signals in an opposite way.

In addition the example configures the CCA and CCB interrupts to update the duty-cycle

Summary of Timer Counter configuration:

  • TCE0 : Timer
  • Compare/Capture modules A/B : Compare and waveform generation in Dual slope mode
  • AXexE : Deadtime Low and High insertion and override of Port E0/E1

This example uses the on-board LEDs to provide user feedback, the output from the LEDs are as follows:

  • LED0: fades out
  • LED1: fades in

Compilation Info

This software was written for the GNU GCC and IAR for AVR. Other compilers may or may not work.

Contact Information

For further information, visit Microchip.