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

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

Re: [avr-gcc-list] Handling High Speed Interrupts


From: Andy Warner
Subject: Re: [avr-gcc-list] Handling High Speed Interrupts
Date: Wed, 22 Sep 2004 08:54:15 -0500
User-agent: Mutt/1.2.5i

Ramkumar Rengaswamy wrote:
> Hi,
>    I have an application that needs to generate a Timer Output Compare
> Interrput every 10 uS. I have an ATMega128L clocked at 7.329 MHz. This
> means that I have 74 clock cycles to handle the interrupt routine and
> currently most of the clock cycles are wasted in pushing and popping
> things off the stack. Is there anyway in avr-gcc to avoid all this
> overhead and utilize all the cycles for my processing only ?

As others have said, __attribute__((naked)) is what you need.
There's no canned #define in the avr header files for this.
This may be a good thing, because you need to use this with
extreme care :)

Bear in mind that interrupt handlers under avr-libc are
basicly functions with reserved names, so whereas before
you wrote:

INTERRUPT(SIG_OVERFLOW1)
{
...
}

This got expanded by the preprocessor to:

void SIG_OVERFLOW1 (void) __attribute__((interrupt))
void SIG_OVERFLOW1 (void)
{
...
}

If you manually implement:

void SIG_OVERFLOW1 (void) __attribute__((naked))
void SIG_OVERFLOW1 (void)
{
...
}

You should generate code like this:

/*
 * Example interrupt handler (T1)
 */
void SIG_OVERFLOW1 (void) __attribute((naked)) ;
void SIG_OVERFLOW1 (void)
{
        PORTB = 0x01 ;
  74:   81 e0           ldi     r24, 0x01       ; 1
  76:   80 93 38 00     sts     0x0038, r24

Which I think is what you want.

Obviously, managaing interrupts and saving/restoring registers
becomes your responsibility - you've told the compiler you want to
take care of it, it's up to you.
-- 
address@hidden

Andy Warner             Voice: (612) 801-8549   Fax: (208) 575-5634


reply via email to

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