Content originally posted in LPCWare by PhysicsGuy on Thu Apr 04 06:30:12 MST 2013
Hi Guys,
I have a little problem with an optimized build on an lpc1769.
The situation is the following. In main, I loop in a while loop, that does nothing but check whether a certain variable is set and when it is set, it calls a function. So
while(1==1) {
if(somevariable==1) do_something();
}
Some variable is set and unset by an external interrupt. Now comes the problem. When I compile with -O1 or higher, the
compiler puts somevariable in a register first and then keep checking the register. However, the interrupt routine ofcourse
does not alter the register value, but rather the value in memory. How can I prevent this from happening? Can I tell the compiler to not make that specific optimization?
thanks!