ATMEL AVR1504 User Manual

http://www.BDTIC.com/ATMEL
AVR1504: Xplain training - XMEGA Event
system

Prerequisites

Required knowledge
Basic knowledge of microcontrollers and the C programming language Completed AVR1500: Xplain training – XMEGA™ Basics Recommended to have finished AVR1501: Xplain training – XMEGA
Timer/Counter
Software prerequisites
Atmel WinAVR/GCC 20100110 or later
Hardware prerequisites
Xplain evaluation board JTAGICE mkII
Estimated completion time
2 hours

1 Introduction

The Event System is a set of features for inter-peripheral communication. It enables the possibility for a change of state in one peripheral to automatically trigger actions in other peripherals. What change of state in a peripheral, that will trigger actions in other peripherals is configurable in software. It is a simple, but powerful system as it allows for autonomous control of peripherals without any use of interrupts or CPU and DMA resources.
®
AVR® Studio® 4.18 SP2 or later
8-bit Microcontrollers
Application Note
The indication of a change of state in a peripheral is referred to as an event. The events are passed between the peripherals using a dedicated routing network called the Event Routing Network. This consists of eight multiplexers, where all events are routed into all multiplexers.
Rev. 8313A-AVR-06/10

2 Introduction to the Event System

http://www.BDTIC.com/ATMEL
This introduction is intended to give you a basic overview of the terminology and behavior which is needed to understand the Event System and the tasks in this training. The tasks in this training will show you how the Event System works in more detail.
The figure below illustrates the Event System. The figure shows the different parts that makes it operate; the event sources, the channel MUX’s and the event action selection in the event user/peripheral.
The figure shows a simplified version with one timer/counter as event generator and one ADC as an event user. The event channel MUX’s can select one of three available sources to be routed though the corresponding event channel.
Events can be generated by the following peripherals:
Timer/Counters (TCxn)
Real Time counter (RTC)
Analog to Digital converters (ADCx)
Analog Comparators (ACx)
Ports (PORTx)
System clock (clksys)
Each of these peripherals has several sources for events. Examples of sources are timer/counter overflow, pin change on a port or A/D conversion completed. The full list of available event sources is shown in the register description for the Event System in the Atmel XMEGA A manual.
The channel multiplexers (MUX) selects what source is routed into each of the 8 event system channels available. Each event system channel allows one source that generates events to that channel. The EVSYS.CHxMUX registers controls the event source for each channel.
2
AVR1504
8313A-AVR-06/10
http://www.BDTIC.com/ATMEL
Events can be used by the following peripherals:
Timer/Counters
Analog to Digital Converters
Digital to Analog Converters
Direct Memory Access Controller (DMAC)
Usage of events is controlled on the individual peripherals. Configuration registers on the individual peripheral allows you to select what event channel to use as input and what the event action is for that channel. Several peripherals can be using the same event channel as input. This is convenient for allowing several actions start at the same time.
For example: starting input capture of a Timer/Counter at the same time as starting a conversion in an ADC. The available event actions are shown in the register description for each peripheral.
AVR1504
8313A-AVR-06/10
3

3 Overview

http://www.BDTIC.com/ATMEL
Here is a short overview of the tasks in this training:
Task 1: 32-bi t Timer/Counter
This task shows the basic Event System setup with event user and event generator and how this can be used for making a 32-bit timer.
Task 2: Input capture with filtering
Input capture with a Timer/Counter is controlled with events in Atmel XMEGA, and this task shows you how flexible this is.
Task 3: Synchronized triggering
More than one peripheral can use events from one event channel, and this can be used to synchronize event actions in the peripherals.
Task 4: Manually generating events
Events can be generated from software, and this task gives you a basic example on how to do this.
GOOD LUCK!
4
AVR1504
8313A-AVR-06/10

4 Task 1: 32-bit Timer/Counter

http://www.BDTIC.com/ATMEL
By using the overflow event from one Timer/Counter as the clock input/source to another Timer/Counter, it is possible to use the Event System for making a 32-bit Timer/Counter. In this setup it is also possible to do input capture in order to have 32­bit input capture. In the Timer/Counter hands-on session we use the Peripheral Clock as input to the timer/counter TCC0, and the event system will be used as input to timer/counter TCC1. The following figure shows this conceptually:
The AVR1001 – using the Atmel XMEGA event system application note contains a code example on how to implement a 32-bit Timer/Counter with input capture.
The goal for this task is that you:
Understand the basics of using the Event System, and how to configure an event channel
Know how to use an event channel in a peripheral module
Understand how to use an event channel to clock a timer
TASK:
AVR1504
1. Locate the Atmel XMEGA-EventSystem folder and open the
32bitTimerCounter.aps project file in AVR Studio
2. Spend some time to understand the code, how it works, and ensure you know the
basics of how the Event System is set up
3. Build the project, ensure there are no errors (you can ignore the warning) and start
a debug session
4. Run the code, and you will see that the LEDs are counting upwards with the clock
tick rate of the most significant TC which is clocked from the event system
5. Break and place a breakpoint as indicated below:
5
8313A-AVR-06/10
Loading...
+ 10 hidden pages