[Top][All Lists]

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

RE: [avr-gcc-list] Enabling and disabling interrutps best practice?

From: stevech
Subject: RE: [avr-gcc-list] Enabling and disabling interrutps best practice?
Date: Sat, 17 Sep 2005 09:44:33 -0700

Cli() and sei() are the usual methods for a global interrupt disable/enable.
Disabling the interrupt enable for a given device is certainly OK, but in my
experience, it is rare that you need to do this detail, if global interrupts
are disabled only for a few instruction times in order to make some RAM
operation atomic (e.g., altering a mult-byte variable which is also used in
an ISR). 

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Sent: Saturday, September 17, 2005 8:14 AM
To: address@hidden
Subject: [avr-gcc-list] Enabling and disabling interrutps best practice?

I have been using the following code segment which according to my
understanding disables all interrupts. Would I be better off just
disabling only the interrupt that could be affected by the code? Most of
the time I am doing this because I need to read or update some variable
that also gets updated in a ISR. I have 2 timer interrupts and 4 uart
interrupts. The one timer interrupt is a straight ms timer that
manipulates 5 delay counters the other is the overflow on my PWM which
only works with 2 variables to set new PWM values. I do not seen any
harm in allowing the overflow to run if I am changing on of the delay
counters. For the 4 Uarts I have a receive and transmit on each of my 2
uarts. The receive and transmit for each uarts have their own set of
variables. It shouldn't hurt to allow uart1's interrupts to fire if I am
manipulating the variables for uart0. Right? Or Am I asking for trouble.
I am not talking about reentrant ISRs but invariable manipulation
outside of the ISRs

uint8_t Sregs;
Sregs =SREG; //save & clear ints
Some code

SREG =Sregs; //restore ints     

AVR-GCC-list mailing list

reply via email to

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