AnsweredAssumed Answered

Blackfin IDLE instruction always gets optimized away

Question asked by KenJackson on Apr 28, 2011
Latest reply on May 12, 2011 by KenJackson

My main() function ends with this loop:

 

for (;;)

{

    idle();

}

 

In debug builds, with optimization off, it gets compiled to these two instructions.

Good!  It's jumping back to the idle instruction, looping forever--just what I want.

 

2000  IDLE

FF2F JUMP.S -2

 

 

 

But in release builds, with optimizing on, it gets compiled to these two instructions.

Bad!  It runs idle once and then loops forever by jumping to the jump.

 

2000  IDLE

0020 JUMP.S 0

 

 

Even when I replace the "idle" function call with this, it get's optimized.

asm("IDLE;");

asm("JUMP.S -2'");

 

I can't find a way to apply the "volatile" keyword.  And "#pragma optimize_off" is ignored.

 

How, oh how, can I keep the IDLE instruction in the loop??

Outcomes