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

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

Re: [avr-gcc-list] volatile...


From: MWare
Subject: Re: [avr-gcc-list] volatile...
Date: Thu, 14 Dec 2006 08:47:50 -0500

Hello Javier,

Javier Almansa Sobrino wrote:
 > Hi everybody. I've a little stupid question....
 > 
 > What's the differece between a volatile variable in a funcion and the 
same variable not volatile?
 > 
 > I've noted a non volatile variable is like don't exists (I think).
 > 

Despite what some have said about this question, I don't think it is 
"stupid" as it pertains AVR-GCC (and other microcontroller compilers).

The way I look at it is:
 ---If you want a GLOBAL to be changed in BOTH real-time-interrupts AND in 
the foreground, you should use VOLATILE (so that the compiler knows this 
variable is capable of changing at any time and dependent code is not 
optimized out of existence).

 ---If you want a GLOBAL to be changed in EITHER real-time-interrupts OR 
in the foreground, you don't have to use VOLATILE (but it doesn't hurt).

Regards,
 - Mike Ware




reply via email to

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