The Three Important Hardware Registers on Atmel Chips 23 May 2014
This is a note to help myself lookup and remember the differences between the three main types of hardware registers on Atmel chips.

DDRx (portx data-direction registers)

These registers control whether each pin is configured as an input or output. Set to 0 for inputs and 1 for outputs.

PORTx (portx data registers)

When the DDRx bit is set to output for a given pin the PORT register controls whether that pin is to logic high (VCC) or low (GND).

When the DDRx bit is set to input for a given pin this will control whether it has an internal pull-resistor attached or whether it’s in a high-impedance state. Whe in the high-impedance state it will effectively electronically disconnect the pin from the circuit.

PINx (portx input pins address)

The PIN register addresses are used to read the digital voltage values for each pin configured as an input. Each PINx memory location is hooked up to a comparator circuit that detects whether the external voltage on the pin is high or low.

You can’t write to PINx registers but you can read from them like normal variables in your code to check which pins are high or low.

Reference: Elliot Williams, Make: AVR Programming


blog comments powered by Disqus