How to add a low priority interrupt

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Eugen

How to add a low priority interrupt

Post by Eugen » Mon May 26, 2008 8:35 pm

Hello,

I have ATmega8 running with AVR-USB and I need to enable a compare match interrupt on Timer1 for a small project.

Knowing the interrupt should start with "sei", I searched and found this paragraph in the AVR Libc 1.6.1 documentation:

The compiler can be instructed to insert an SEI instruction right at the beginning of an interrupt handler by declaring the handler the following way:

ISR(XXX_vect, ISR_NOBLOCK)
{
...
}

where XXX_vect is the name of a valid interrupt vector for the MCU type in question, as explained below.


I declared the interrupt that way in the main.c file, but I got the following error message:

static declaration of __vector_3 follows non-static declaration


What could be the cause for the compile error? (The USB driver works great without the interrupt addition, but I need the timer interrupt.)

Thanks for your help!

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Wed May 28, 2008 5:28 pm

I use

Code: Select all

#define UTIL_INTERRUPT(signame)                         \
    void signame (void) __attribute__ ((interrupt));    \
    void signame (void)

and declare the interrupt as

Code: Select all

UTIL_INTERRUPT(XXX_vect)
{
    ... interrupt implementation
}

Post Reply