Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: Any way to make interrupts faster, please?

2010-01-20 by Don Kinzer

>I seem to remember that there's a way to tell the compiler to not do >context saving/restoring when going into an ISR on ATMega chips
If you can do so and how you do so depends on the compiler you're using.  For avr-gcc, for example, you can add the "naked" attribute to the declaration of an ISR.  That attribute directs the compiler not to generate the usual prologue/epilogue (including the reti).  Unless you absolutely know what you're doing, however, it is probably a bad idea to do this.

If you need an ISR that takes less time, you may have to resort to coding it entirely in assembly language.  This can be easy or difficult depending on what needs to be done in the ISR and your experience level.

Another option is to reduce the amount of work done in the ISR and, importantly, avoid calling other functions, doing complicated math operations, floating point, etc.

What does your ISR do and how much time is it taking?  By how much do you need to reduce the execution time?

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.