Robin2:
What does this doPORTB ^= (1 << PORTB0);
I can never get my head around that notation. Can you express the RHS as a binary value?
I'm wondering if bits are mangled in PORTB that should not be mangled.
...R
Toggles bit zero in PORTB, i.e. PORTB = PORTB ^ 0x01;
Shouldn't mangle any other bits.
Common idiom, worth mastering.
PS: But it is not an atomic operation, so if not executed with interrupts inhibited (as it is here by virtue of being in an ISR), it could cause unintended results.