Microchip® Advanced Software Framework

•All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Drivers TC Example for Simulator XMEGA A1 Documentation

Introduction

This simple example shows how to use the Timer Counter (TC) to toggle LEDs.

Main files:

  • tc.c Timer XMEGA Timer Counter driver implementation
  • tc.h Timer XMEGA Timer Counter driver definitions
  • tc_example1.c example application
  • conf_example.h: configuration of the example

TC Driver

The XMEGA TC driver can be found here.

Device Info

All AVR XMEGA devices with an tc can be used.

Description of the example

The example will configure one TC module (TIMER_EXAMPLE) in normal mode and use three TC interrupts (overflow, Capture/Compare Channels A and B).

The TC is setup to use a 31250Hz resolution clock and a 31250000 period value resulting in a 1kHz TC overflow frequency. Compare Channels A and B will be setup at 1/4 and 1/2 of the TC period.

Each callback interrupts functions are setup to toggle a LED.

  • PORTA0 GPIO: Toggles on TC overflow interrupt
  • PORTA1 GPIO and PORTA2 GPIO: Toggle on Compare Channel A and B interrupts

Compilation Info

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

Contact Information

For further information, visit Microchip.