When browsing through the datasheets of the ATmega processors, most of the time my eyes just glaze over this diagram. I never really put much thought into it.
But zooming in, you'll notice a special feature of the Atmel's Pin register...
First, you start by finding the PORT flip-flop which is the PORTxn symbol directly above the RESET signal in the diagram above. Notice that it's output is on the left and it's flipped and fed back into itself on the right?
That's not really that exciting, right?
Wrong! Because if you write a 1 to the Pin register WPx (input to the AND gate), you'll be able to toggle the output state of the port!
So why is this interesting? It's interesting because you can now toggle the I/O pins at blazing fast, single instruction speeds :-)
The code to toggle PORTB 7 might look something like this:
DDRB = 0b10000000;
PINB = (1 << 7);