avr-gcc-list
[Top][All Lists]
Advanced

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

RE: [avr-gcc-list] Question about gcc preprocessing and port/pin assignm


From: Dave Hylands
Subject: RE: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments
Date: Wed, 8 Dec 2004 13:07:09 -0800

Hi Graham,

In your example:



> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On Behalf Of Graham Davies
> Sent: Wednesday, December 08, 2004 11:43 AM
> To: address@hidden
> Subject: Re: [avr-gcc-list] Question about gcc preprocessing 
> and port/pin assignments
> 
> 
> I agree with Dave that there's more to volatile than
> someone-else-might-change-it.  A variable must be declared volatile if
> access to it can have side-effects.  This is generally true 
> of registers
> that control hardware.  Dave provided good examples.
> 
> I reported a defect to ZiLOG in their ZDS II for Z8 Encore! 
> related to this.
> I wrote something like this:
> SOME_REG = (SOME_REG & 0xFE) | 0x02;
> where SOME_REG is declared volatile and the intent is to flip 
> the state of
> two enable signals to external hardware devices.  The machine 
> code produced
> enables the second device and then disables the first in two 
> successive
> instructions.  My argument is that since SOME_REG is volatile 
> the compiler
> is supposed to do exactly as I say and so it must evaluate 
> the right hand
> side of the assignment and write once to SOME_REG, even if 
> this is not as
> fast as writing twice to SOME_REG.  So far I have been unable 
> to convince
> ZiLOG that what they're doing is wrong.  This and similar 
> episodes explains
> my switch to AVR.
> 
> By the way, I realize that flipping the enables at the same 
> time may be
> borderline in some cases but I have checked the timing and 
> it's OK in this
> case.  Having them both enabled for a few hundred nanoseconds 
> may not be so
> bad either, but what if an interrupt comes along between the two
> instruction?
> 
> Graham.
> 
> 
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
> 
> 



reply via email to

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