avr-gcc-list
[Top][All Lists]
Advanced

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

RE: [avr-gcc-list] avr-c++ can I use templates to avoidcreatingunnecessa


From: Stu Bell
Subject: RE: [avr-gcc-list] avr-c++ can I use templates to avoidcreatingunnecessary ISRs?
Date: Tue, 14 Sep 2010 11:36:11 -0600

> On Behalf Of Weddington, Eric
> > On Behalf Of Michael Clift
> > 
> > Hi Robert, just a thought...
> > 
> > If the user wanted to programatically assign ISR's to either your 
> > library handleInterrupt<id>() functions, or their own 
> > functions, then maybe the main application should contain ISR()'s
> > which call function pointers?  The function pointers could then
> > be loaded with either the address of your library functions, or
> > the users own functions.
> > 
> 
> That could work... Those are typically called "callback" 
> functions. Note that there is a tradeoff with doing that: 
> Because a function will be called in an ISR, the ISR prologue 
> and epilogue will be bloated out because of having to 
> save/restore a lot of registers. Just a warning.

One other caveat - this idea won't work consistently without some
juggling on an ATmega2560 (or any AVR with more than 128 Kbytes of
Flash).  You will need to force all of the ISRs and the targets of the
function pointers into the bottom half of flash to avoid the 16-bit
function pointer limitation.

It's actually pretty simple to work up a mildly customized linker script
and a macro for the function targets and ISRs to force them into special
memory section in low memory.  See my posting in AVRFreaks.net under
Tutorials for FreeRTOS on the ATmega2560 for an example of how to do
this.

Best regards, 

Stu Bell 
DataPlay (DPHI, Inc.) 



reply via email to

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