We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
thank you ! my friends!
A nice article: http://www.programmersheaven.com/articles/pathak/article1.htm
If a variable can change for any reason other than being manipulated by a local bit of code, it should be declared volatile. Common reasons for this sort of behavior include hardware registers that update whether or not the code touches them, hardware where the actual read or write cycle causes some operation to take place, global variables shared with ISRs (local code has no idea whether an ISR occurs and changes the variable, just as it wouldn't know if hardware updated itself), and memory shared between different processes. The volatile keyword essentially forces the compiler to re-read the value of a variable, rather than using an older value might still have in registers.