Content originally posted in LPCWare by blasiis on Wed May 26 02:21:52 MST 2010
Quote: nerd62
Hi blasiis,
__IO is a preprocessor symbol which is defined to "volatile" (as rkiryanov wrote this). The "volatile" attribute tells the optimizer not to optimize too much. The content of the register may be changed by an other process from what the optimizer does not know about - so the content of the register has to be read everytime when there are made decisions which depend on the true content. When the optimizer does not know about the "volatile" attribute he may have the idea to copy the content of the IO-register into a general purpose register and make further decisions with the content of this general purpose register. This may work in one case - when you make small changes at your code it suddenly won't work. This leads e. g. to polling loops which suddenly don't terminate. I have spent a lot of time to debug such (homebrewed) errors in my last project.
Have much fun with your LPC, nerd62 ;-)
Therefor for safety reasons it is best to put it in structure or similar