Problem with optimized build

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with optimized build

656 次查看
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 项奖励
回复
1 回复

643 次查看
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 项奖励
回复