http://www.BDTIC.com/ATMEL
AVR1503: Xplain training - XMEGA
Programmable Multi Interrupt Controller
Prerequisites
• Required knowledge
Completed AVR1500 XMEGA™ Basics training
• Software prerequisites
Atmel
WinAVR/GCC 20100110 or later
• Hardware prerequisites
Xplain evaluation board
JTAGICE mkII
• Estimated completion time:
1.5 hours
1 Introduction
Atmel XMEGA has an advanced Programmable Multi-level Interrupt Controller
(PMIC). The PMIC allows control over interrupt priorities and scheduling of
interrupts.
In this hand-on we will learn more about the Atmel XMEGA Programmable
Interrupt Controller.
®
AVR® Studio® 4.18 SP2 or later
8-bit
Microcontrollers
Application Note
Rev. 8312A-AVR-06/10
2 Introduction to the PMIC
http://www.BDTIC.com/ATMEL
Atmel XMEGA has a Programmable Multi-level Interrupt Controller (PMIC). All
peripherals can define three different priority levels for interrupts; high, medium or
low. Medium level interrupts may interrupt low level interrupt service routines. High
level interrupts may interrupt both low and medium level interrupt service routines.
Low level interrupts have an optional Round Robin scheme to make sure all interrupts
are serviced within a certain amount of time.
3 Overview
This training session covers the basic features of the Atmel XMEGA Programmable
Multi-level Interrupt Controller (PMIC). The goal of this training is to get you started
with simple interrupt handlers, using the priority levels and scheduling features of the
PMIC to create robust interrupt controlled applications.
Here is a short overview of the tasks in this training:
Task 1: Overflow Interrupt
This task shows how to create a simple interrupt handler for a timer overflow interrupt.
Task 2: Interrupt Levels
This task shows how different interrupt levels interact.
Task 3: Round Robin
This task shows how interrupt priorities can cause starvation of interrupts with lower
priority, and how the Round Robin scheduling feature can be used to prevent
starvation.
GOOD LUCK!
2
AVR1503
8312A-AVR-06/10
4 Task 1: Overflow Interrupt
http://www.BDTIC.com/ATMEL
Blinking LEDs are fun, but interrupt controlled blinking LEDs are more fun! This task
shows the necessary steps to configure a timer and enable its overflow interrupt to
blink an LED for us.
The goal for this task is that you know how to:
• Write an interrupt handler function, and associate it with the corresponding
interrupt vector
• Enable an interrupt source such as a timer’s overflow interrupt, and select the
interrupt level
• Configure the PMIC to let through interrupts of a certain level, and to enable
interrupts globally
TASK:
1. Locate the XMEGA-PMIC folder, find the Task 1 folder and open the
OverflowInterrupt.aps project file in Atmel AVR Studio
2. Look through the code and ensure you understand how things are set up
3. Notice how easy it is to change LEDPORT and LEDMASK definitions, if you want
another LED port and/or other LEDs than the default one
4. Build the project and start a debug session (click on the Play icon) in AVR Studio
5. Place a breakpoint (F9) inside the interrupt handler, run the code (F5) and observe
it stopping at the breakpoint
AVR1503
6. Remove the breakpoint (F9 again) and run the code to see the LED blink
7. Feel free to change interrupt levels, and timer speed. Recompile and run again
8312A-AVR-06/10
3