Skip to main content
Arman Ilmak
Senior
Aug 30, 2019 12:16 PM UTC
Question

Weird bug in stm8 IAR compilers ?

Hi.

I have faced a weird problem using IAR compilers.

Errorstatus=0;
 Relay_Off;
 delay_ms(200);
 if(Errorstatus==1){
 Errorflag=1;

In this part of my code after I switch the relay off, I put a delay and if an interrupt occurs Errorstatus mentioned in the code changes from 0 to 1 in interrupt handler and the if must change the Errorflag from 0 to 1, but it wont work though Errorstatus is changed from 0 to 1!!

What is the problem?

    This topic has been closed for replies.

    4 replies

    After Forever
    Senior III
    Aug 30, 2019 1:06 PM UTC

    Make sure both Errorflag and Errorstatus are declared as volatile if you change/access them in the interrupt handler.

    Arman Ilmak
    Senior
    Aug 30, 2019 1:18 PM UTC

    I have defined them as int variables.

    After Forever
    Senior III
    Aug 30, 2019 1:20 PM UTC

    Change to volatile int and try again.