[Top][All Lists]

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

Re: [avr-gcc-list] On getting an ISR leaner with GCC

From: dlc
Subject: Re: [avr-gcc-list] On getting an ISR leaner with GCC
Date: Mon, 29 Dec 2008 08:43:50 -0700
User-agent: Thunderbird (Macintosh/20081105)

Thanks all for the suggestions. I was tempted by the "naked" function, but that required a total re-write mostly in assembly to get it right and I have found that sometimes the "register" variables get slammed by something else, so something I was doing wasn't reliable. The code generated by gcc was so bloated in the ISR that I was tempted also to rewrite sections in assembly to fix it up, but again balked at getting the C and assembly sides to agree on symbolic variable names/locations.

I ended up simply changing IO lines and moving a set of polled lines to the INT0 and INT1 IRQ's and counting level changes. That reduced the use of the 10us IRQ significantly since the polled lines would change only every few dozen milliseconds. They really needed their own ISR's, which ran pretty quickly regardless. I was simply trying to do too much in one ISR and overloaded it. My change sucked about 100 bytes out of the ISR.

I have been spoiled by the PIC 18F series autosave of status and pointer registers and defining certain variables as only changed in the ISR, this allowed very lean ISR code with little overhead. Gcc and the AVR may allow better C code than the PIC, but ISR's have to be much more carefully considered!

have fun,

Bob Paddock wrote:

Look up:


That should get you down to the bare metal where you have to do it all.

On Sat, Dec 27, 2008 at 2:52 AM, dlc <address@hidden <mailto:address@hidden>> wrote:

    The subject says it all.  I've an ISR that is using too many cycles
    for something that kicks every 10us.  I'm very experienced with the
    PIC and know how to specify registers that are not touched outside
    of the ISR to avoid lots of "push-n-pop" actions.  Is there
    something like that in the AVR toolchain or am I going to have to
    resort to assembly to get this thing leaned down?  I'd like to
    create some memory that is dedicated to the ISR such that the
    compiler knows that it doesn't need to be saved. Also a way to get
    scratchpad memory assigned to it for some basic math that I don't
    want to have to use the overhead of push/pop.  Can anyone offer
    insight into how I can lean an ISR down or what sorts of operations
    or memory types to avoid there with avr-gcc?

    many thanks,
-- -------------------------------------------------
    Dennis Clark          TTT Enterprises
    www.techtoystoday.com <http://www.techtoystoday.com>

    AVR-GCC-list mailing list
    address@hidden <mailto:address@hidden>


Dennis Clark          TTT Enterprises

reply via email to

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