Hi,
I have a clue about doing tests on a bit in a byte
In this example, I try to look if bit 3 is set in byte "mot4" and do something. to do the test I use
But it doesn't operate.
Can someone point me to my problem ?
I know that something like
can work, but the first method should too ?
Thanks,
Manu
I have a clue about doing tests on a bit in a byte
Code:
byte mot4 = frame.buf[4];
Serial.print("buff 4 : "); Serial.println (mot4, BIN);
if ((mot4 & 0x04) == 1) {
resetCPU();
}
if ((mot4 & 0x08) == true) {
razconfModule();
return;
}
In this example, I try to look if bit 3 is set in byte "mot4" and do something. to do the test I use
Code:
if ((mot4 & 0x04) == 1)
But it doesn't operate.
Can someone point me to my problem ?
I know that something like
Code:
if ((mot4 >> 3) & 1U) == 1)
Thanks,
Manu