avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Interrupt vector redirection scheme


From: Dave Hylands
Subject: Re: [avr-libc-dev] Interrupt vector redirection scheme
Date: Mon, 3 Sep 2007 07:57:25 -0700

HI Michael,

> If you want to allow that behavior in C, it looks like that:
>
> typedef void (*funcpointer)(void);
>
> funcpointer     fp;
>
> ISR(TIMER1_OVF_vect)
> {
>          if (fp)
>                  (*fp)();
> }
>
> Attention: The function pointer has to be set with interrupts disabled,
> because of changing a word and on the AVR isn't atomically.

There's already a vector table. Each entry consists of an rjmp (or
jmp) instruction to a named routine. Right now the ISR macros uses
numbers to line up the routines. By creating a new macro which
declares the ISR handler correctly, but uses a name rather than a
number, you could then write a function which fabricates the
appropriate rjmp (or jmp) instruction and stuffs into the existing
vector table. No performance hit at all.

-- 
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]