I am writing a function having an infinite while loop, with nested if else statements in it.
The 'if else' statements depend on a single variable 'state' which is an unsigned integer.
The value of state is initialized to 1 while declaring it. The if statement when state == 1 is evaluated successfully and changes the value of 'state' to 2, but when value of 'state' becomes 2, the 'else if' statement is not evaluated and the code returns back to main if.
Platform: MSP430fr4133 Launchpad, CCS v6.1.0
The code is as follows (The code is inside a function body with no arguments and no return):
unsigned char receivedChar;
volatile unsigned int state;
state = 1;
while(1)
{
//If queue is not empty
if(!isEmpty(&REC_q))
{
//Get the character from the queue
receivedChar = dequeue(&REC_q);
if(state == 1){
//Do something
state = 2;
}
else if(state == 2){
//Do something
}
}
}

