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: Michael Schulze
Subject: Re: [avr-libc-dev] Interrupt vector redirection scheme
Date: Mon, 03 Sep 2007 18:27:54 +0200
User-agent: Thunderbird 1.5.0.12 (X11/20070719)

Hi Dave,

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.

Yes, of course and I know this. The redirection scheme of me uses the vector table and provides a way for binding ISRs at runtime. In my opinion, the above C-code is functional equivalent to my proposed solution. However, my scheme is cheaper in terms of resource usage.

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.

Sorry, but I don't understand what you meant. Could you it explain? Allows your scheme dynamic changing of ISRs at the runtime?

Regards,
Michael

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

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