Page 1 of 1

How to add a low priority interrupt

Posted: Mon May 26, 2008 8:35 pm
by Eugen
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!

Posted: Wed May 28, 2008 5:28 pm
by christian
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
}