Forum Discussion
Altera_Forum
Honored Contributor
11 years agoIf a variable (or structure member) is marked 'volatile' then the compiled has to assume that unknown (to the code flow) accesses to that variable might happen, and the compiler must not cache the value in a register.
For example, if you want to wait for an interrupt to change something, the code:int x = 0;
...
while (x == 0)
continue; won't work becuse the compiler will generate code that only read 'x' once. Use 'volatile int x;' and the compiler will generate code that reads 'x' every time around the loop. 'static' just indicates that the symbol is only visible in current source file. What you might find is that just getting into your ISR is taking so many instructions that there aren't enough left for any useful work.