I've noticed that in the case where I have to wait in a while loop until some special bit is set by an ISR, the program never goes past this point even though the interrupt does occur.
while( (sfr & (1 << BIT_VAL)) == 0 );
So I've tried putting a NOP in the while loop using a macro that looks like this:
#define NOP() asm volatile("nop\n\t"::)
while( (sfr & (1 << BIT_VAL)) == 0 )
{
NOP();
}
but it makes no difference. When I put in the winavr delay function though, the ISR updates the variable and the program can continue.
What is the reason for this?