[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Customizing interrupt vector entries when using GCC?
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] Customizing interrupt vector entries when using GCC? |
Date: |
Thu, 16 Feb 2006 11:40:42 +0100 (MET) |
(Please don't crosspost.)
Rick Mann <address@hidden> wrote:
> I'm working on an ATmega128, using avr-gcc, and I need to speed up
> the handling of interrupts on three pins INT5, INT6 and INT7. Rather
> than creating three interrupt handlers that all call a single
> unified handler, I'd like to put the same handler in each of those
> three slots in the vector.
The obvious solution would be to write all of it in assembly language,
and supply multiple labels to the ISR:
#include <avr/io.h>
..global INT5_vect
INT5_vect:
..global INT6_vect
INT6_vect:
..global INT7_vect:
INT7_vect:
;; do something here
reti
There's a GCC feature of an `alias' attribute, so in C you could
write:
#include <avr/io.h>
#include <avr/interrupt.h>
ISR(INT5_vect)
{
/* do something here */
}
void INT6_vect(void) __attribute__((alias("INT5_vect")));
void INT7_vect(void) __attribute__((alias("INT5_vect")));
Alas, when trying this, GCC says:
foo.c:9: warning: alias definitions not supported in this configuration; ignored
foo.c:10: warning: alias definitions not supported in this configuration;
ignored
(Also, I'm not sure whether the macro expansion for INT5_vect would
work inside the double quotes, probably not. Perhaps you'd have to
write __vector_6 instead.)
Finally, you could apply the alias on the linker command-line. For my
simple example, the respective compiler command would look like:
avr-gcc -mmcu=atmega128 -Os \
-Wl,--defsym=__vector_7=__vector_6 \
-Wl,--defsym=__vector_8=__vector_6 \
-o foo.elf foo.c
As you can see, plenty of options without really touching gcrt1.S. :)
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/