Playing with a p18lf25k22, XC8 on MPLABx
When I press a button it triggers an interrupt and sets a flag bit in a register (two bits actually, B7 and B0):
Like this: Button Press --> Interrupt ---> 0b10000010 ==> flag_register
In the main code loop I then test for the flag and if it's set I run some other code:
if ((status_flags & 0x00000010)) //if button pressed do this code...
{
__delay_ms(30);
__delay_ms(30);
//do some stuff.......
}
My problem is the execution never passes the "if" test, it is as if the "if" always tests false.
If I step through the program and mouse over the status_flags variable it shows the contents as 0x82 = 0b10000010 which is what
I expect. I'm trying to test if bit1 is set. Why doesn't it work?
Thanks.
