Re: while(flag)

"David W. Schultz" <[email protected]> Sun, 8 Nov 2015 16:17:41 -0600
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.user
Organization State of Total Disorganization
Message-ID <[email protected]>
On 11/08/2015 04:01 PM, Ian Chapman wrote:
> Hi all,
>       I'm having difficulty understanding this situation.
> flag = 1;
> while ( 0 != flag )
> {
> code;
> }

If flag is changed within an interrupt, it must be declared as volatile:

volatile int flag;

Otherwise the compiler will see that it never changes and optimize
accordingly.

-- 
David W. Schultz
http://home.earthlink.net/~david.schultz
Returned for Regrooving



------------------------------------------------------------------------------