Problem with optimized build

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with optimized build

443 Views
lpcware
NXP Employee
NXP Employee
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!
0 Kudos
Reply
1 Reply

430 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Apr 04 07:05:32 MST 2013
Read this FAQ:
http://support.code-red-tech.com/CodeRedWiki/CompilerOptimization
0 Kudos
Reply