[Top][All Lists]

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

Re: [avr-gcc-list] interrupt in as

From: Tor Ringstad
Subject: Re: [avr-gcc-list] interrupt in as
Date: 09 Oct 2001 21:53:04 +0200

[Torsten Hahn]
> The Problem is now, that i have an extremly time critical
> applikation and i have for some reasons only 16 (!) takt-cycles to
> handle this interrupt optimal.

With this kind of restraint, pure assembly may indeed be the best (or
even only) way to go.

[Clemens Gerlach]
> use __attribute__((naked)) for the function to avoid pro/epilog.
> you have to save registers and status by yourself.

Before you go for the "naked" C-functions variant, just be sure you
understand what the prologue and epilogue really do.

- It saves/restores the contents of SREG, which you don't want the ISR
  to accidentally change. However, as Clemens Gerlach shows, it's
  possible to write ISR code that doesn't touch the SREG.

- It clears r1, which is assumed by all generated C code to have the
  value zero. This is important if your function is to contain any C
  code at all.

- It saves/restores the contents of all registers that are used. The
  reason for this is obvious.

You should also notice, that for a little less restrained situation,
writing in C really is an option worth considering. With a little
care, you can get the compiler to generate reasonably compact code.

- Tor Ringstad -

reply via email to

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