I have an interrupt handler that toggles an output pin between on and off each time it runs.
If I use a variable and then assign its value to the port register then it works as expected:
...but If I eliminate the variable, or try to use bitwise logic directly on the pin then the pin just turns on and stays on. None of these work:
Any help is appreciated.
If I use a variable and then assign its value to the port register then it works as expected:
Rich (BB code):
toggle = 1 - toggle;
PORTCbits.RC2 = toggle;
Rich (BB code):
PORTCbits.RC2 = 1 - PORTCbits.RC2;
Rich (BB code):
PORTCbits.RC2 = !PORTCbits.RC2;
Rich (BB code):
PORTCbits.RC2 ^= 1;