[Top][All Lists]

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

[avr-gcc-list] Re: On the subject of lean ISR's

From: David Brown
Subject: [avr-gcc-list] Re: On the subject of lean ISR's
Date: Wed, 25 Feb 2009 22:19:13 +0100
User-agent: Thunderbird (Windows/20081209)

Dennis Clark wrote:
Rather than hijack a thread I'll start my own.

How does everyone lean out an ISR?  I too have been appalled at the
preamble/postamble code GCC puts into the ISR.

I always put ISR variables in global space to avoid stack issues, but the
heap access registers still need push/popped.  I tried using register
variables to avoid heap access and found that there is no way to know if a
library call is using that register - The compiler does NOT guarantee
exclusive access.  Can you actually get away with a "NAKID" attribute on
the ISR?

How have others dealt with ISR bloat reduction?

Many thanks,

Use local variables rather than global ones where you can - it is always more efficient.

The biggest cost to the ISR preamble and postamble comes if the ISR makes a function call - all registers that the function *might* use have to be stacked for safety. So in general, avoid function calls (inlined functions are fine).

However, if you have a very complex ISR (which is generally a bad idea - it's better to keep ISR's short and simple) so that your preamble is already fairly long, then any rarely-executed sequences can be put in a function (perhaps declared "noinline"), so that any additional pushing and popping is only done when that function actually runs.

reply via email to

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