Problem with optimized build

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem with optimized build

442件の閲覧回数
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 返信

429件の閲覧回数
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 件の賞賛
返信