Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TC Example 1 for XMEGA-A1 Xplained 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 31250 period value resulting in a 1Hz 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.

  • LED0: Toggles on TC overflow interrupt
  • LED1: Toggle on Compare Channel A In the case of A1 Xplain:
  • LED2: Toggle on Compare Channel B interrupts In the case of A3BU Xplained:
  • Status LED: Toggles red on Compare Channel B interrupts

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.