Search code examples
cavr

AVR: if statement


I am new in AVR programming. I would like to control a variable (uint8_t received_msg) if it is equal to 0xFF. would it be correct to do:

if (!(received_msg ^ 0xFF))

or do I need to compare bit by bit

    uint8_t test = 0;
    test = received_msg ^ 0xFF 
    for (i =0; i<8; i++){
     test = 0 & (1<<received_msg)
    }
    if(test==0)

Solution

  • If you want to know if a variable is equal to 0xff, just test for equality:

    if (received_message == 0xff)