avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] Disable/Restore all Interrupts


From: Sam de Jongh Hepworth
Subject: Re: [avr-libc-dev] Disable/Restore all Interrupts
Date: Sun, 7 Sep 2003 02:16:25 +0200

Hi

Nice to know that you looked at my email. I noticed the { and } in the
macros have raised some debate. Well the macros compile just fine - and the
brackes have two functions:

1. It allows me to create a "temporary variable" to store the status of SREG
2. The compiler will complain if you forget RESTORE_INTERRUPTS();

Anyway I suspect may people use "sei" and "cli" in situations where a
"nested" solution (like mine) would be much better. At least I did for a
while...

/Sam

----- Original Message ----- 
From: "Joerg Wunsch" <address@hidden>
To: <address@hidden>
Cc: "Sam de Jongh Hepworth" <address@hidden>
Sent: Friday, September 05, 2003 3:38 PM
Subject: Re: [avr-libc-dev] Disable/Restore all Interrupts


> As Theodore A. Roth wrote:
>
> > Note that sei() has it's place. You can use it once to initially
> > enable interrupts.
>
> Also, you can use it in situations where you're sure that interrupts
> have been disabled previously (like it's usually the case in the
> application's main loop).  While saving SREG in a temp reg is
> certainly the safe way, it would waste the storage for a temporary
> register in these situations.
>
> > It's debatable whether saving and restoring only the I flag gains you
> > anything.
>
> You can be sure to not clobber any flags the compiler expects to
> persist.  IMHO, just saving the entire SREG is only safe in the
> function prologue/epilogue, or am i missing something here?  Does the
> compiler perhaps automatically expect the flags to be clobbered as
> soon as a single inline asm statement is executed?
> -- 
> J"org Wunsch        Unix support engineer
> address@hidden
http://www.interface-systems.de/~j/
>





reply via email to

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