[Top][All Lists]

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

Re: [avr-gcc-list] interrupt optimization

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] interrupt optimization
Date: Wed, 1 Feb 2006 22:55:06 +0100 (MET)

"David Bourgeois" <address@hidden> wrote:

> ISR(...)
> {
>      if (sampling-- == 0)
>      {
>          sampling = 0x7F;
>          callInlineFunction();
>      }
> }

> What's the way to go in this situation?

Two things: I'm not sure, but I guess the compiler handles an inlined
function the same way as any other function, i.e.  it treats any
call-clobbered register as something that needs to be pushed upon
entering the ISR.  So it's usually best to avoid any kind of function
call inside the ISR.

If that doesn't help, code it completely in assembly.

__tmp_reg__ = 0
__SREG__ = 0x3d

.global XXX_vect
        push    __tmp_reg__
        in      __tmp_reg__, __SREG__
        push    r16

        lds     r16, sampling
        and     r16, r16
        brne    1f
        ldi     r16, 0x7f
        ;; do some stuff here
        rjmp    2f
        dec     r16
2:      sts     sampling, r16

        pop     r16
        out     __SREG__, __tmp_reg__
        pop     __tmp_reg__

cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

reply via email to

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