2.2 Register Description

Each port pin consists of three register bits; DDRxn, PORTxn, and PINxn (x is port number, n is bit number). DDRxn is port pin input/output direction register, PORTxn is port pin data register, and PINxn is port pin input register.

The DDRxn bit in the DDRx register selects the direction of this pin. If DDxn is written to '1', Pxn is configured as an output pin. If DDxn is written to '0', Pxn is configured as an input pin.

When the pin is configured as an output pin, if PORTxn is written to '1', the port pin is driven high; if PORTxn is written '0', the port pin is driven low.

The table below summarizes the control signals for the pin value.

Table 2-1. Table 3-1: Port Pin Configurations
DDRxnPORTxnPUD (pull-up disable, in MCUCR)I/OPull-upComment
00XInputNoTri-state (Hi-Z)
010InputYESPxn will source current if ext. pulled low
011InputNoTri-state (Hi-Z)
10XOutputNoOutput Low (Sink)
11XOutputNoOutput High (Source)