I want to ask if I want to toggle an IO bit such as bit 5 of Port A. Which one of the following is correct?
DDRA|=BV(5); PORTA^=BV(5);
or
unsigned char uc; DDRA&=~BV(5); uc=PINA&BV(5); DDRA|=BV(5); PORTA=uc^BV(5);
If the second one is correct, could I find do it faster (use fewer instructions) to replace them?