vendredi 16 juin 2017

C++ While(1) loop is not calling if statement inside it

I've got an interrupt that sets a flag, a bool called recvd as so:

while (radio.available())
          {
            // Fetch the payload, and see if this was the last one.
            radio.read( &receive_payload, len );
            recvd = 1;
    radio.writeAckPayload(1,&ack,sizeof(ack));
    }

In my main() I've got a while(1) loop and a simple if statement checking if the flag has been set to 1:

// forever loop
while(1){
if (recvd == 1){toFloat(12);recvd = 0;}
}
}

This function is never called, even though I can put a printf inside the interrupt handler giving the value for recvd and it spits out 1. Any Ideas? Interestingly enough, when I put a random character printf just in the root of the while statement the if clause is called.

Aucun commentaire:

Enregistrer un commentaire