[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] "Volatile"
From: |
Keith Gudger |
Subject: |
Re: [avr-gcc-list] "Volatile" |
Date: |
Mon, 18 Apr 2005 06:54:08 -0700 (PDT) |
On Mon, 18 Apr 2005, David Brown wrote:
> Note that the assignment is atomic even if the assembly consists of more
> than one instruction (e.g., something like ldi r16, #1; st r16, flag ). The
> point of an "atomic" access is that there is no way to break the statement
> into a "half-done" step, as viewed by interrupt functions or external
> accesses of some sort. Even if an interrupt occured between these two
> instructions, the flag change itself would not be affected - thus it is
> atomic.
>
I think I missed something here. Why would :
ldi r16, #1;
st r16, flag
Necessarily be atomic? If an interrupt occured between these 2
instructions, and the interrupt changed the state of flag, wouldn't there
still be the original problem?
On to a solution, since disabling interrupts is not portable, would
something like the following be an OK solution?
void Flags_Clear(unsigned char x)
{
CRITICAL_SECTION_BEGIN
cFlags &= ~x;
CRITICAL_SECTION_END
}
Where the CRITICAL_SECTION stuff are macros, defined on a per machine
basis?
Thanks to everyone for all their help on this issue!
Keith
- [avr-gcc-list] "Volatile", Keith Gudger, 2005/04/15
- Re: [avr-gcc-list] "Volatile", E. Weddington, 2005/04/15
- Re: [avr-gcc-list] "Volatile", David Brown, 2005/04/17
- Re: [avr-gcc-list] "Volatile", Jeff Epler, 2005/04/17
- Re: [avr-gcc-list] "Volatile", David Brown, 2005/04/18
- Re: [avr-gcc-list] "Volatile", Graham Davies, 2005/04/18
- Re: [avr-gcc-list] "Volatile", David Brown, 2005/04/18
- Re: [avr-gcc-list] "Volatile",
Keith Gudger <=
- Re: [avr-gcc-list] "Volatile", David Brown, 2005/04/18
- Re: [avr-gcc-list] "Volatile", David Kelly, 2005/04/18
- Re: [avr-gcc-list] "Volatile", David Brown, 2005/04/19
- RE: [avr-gcc-list] "Volatile", stevech, 2005/04/20
- Re: [avr-gcc-list] "Volatile", Colin Paul Gloster, 2005/04/20
- Re: [avr-gcc-list] "Volatile", E. Weddington, 2005/04/20
- Re: [avr-gcc-list] 'Volatile', Mike Murphree, 2005/04/20
- RE: [avr-gcc-list] "Volatile", Geoffrey Wossum, 2005/04/20
- Re: [avr-gcc-list] "Volatile", E. Weddington, 2005/04/18
- Re: [avr-gcc-list] "Volatile", David Brown, 2005/04/18