You are on page 1of 8

Atmega 16

Port Configuration
I/O-Ports
All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports. This
means that the direction of one port pin can be changed without unintentionally changing the direction
of any other pin. The same applies for changing drive value or enabling/disabling of pull-up resistors.
PortA
Port A is an 8-bit bi-directional I/O port with individually selectable internal pull-up resistors.
The PORT A output buffers can sink 20mA and thus drive LED displays directly.
It should be noted that the supply voltage for Port A comes from the Avcc pin.

http://web.ics.purdue.edu/~jricha14/Port_Stuff/PortA_general.htm
Port A has an alternate function as analog inputs for the
ADC.


http://web.ics.purdue.edu/~jricha14/Port_Stuff/PortA_ADC.ht
m
PortB
Port B is an 8-bit bi-directional I/O port with individually selectable internal pull-up resistors.
The PORT B output buffers can sink 20mA and thus drive LED displays directly.


PortD
Port D is an 8-bit bi-directional I/O port with individually selectable internal pull-up resistors.
The PORT D output buffers can sink 20mA and thus drive LED displays directly.
PortC
Port C is an 8-bit bi-directional I/O port with individually selectable internal pull-up resistors.
The PORT C output buffers can sink 20mA and thus drive LED displays directly.
DDR Data Direction Register


DDR register points the MCU about the status of a pin as output(giving results) or input(taking
values).This status is assigned Port-wise to ports A,B,C,D.


1 assigned to a pin by DDR register implies it being an output pin.
0 assigned to a pin by DDR register implies it being an input pin.


Usage: DDRX=<value> . Where X is to replaced by either A or B or C or D
Eg: DDRA = 000 .. implies all 8 pins are input
Eg: DDRA = 0xFF implies all 8 pins are output
Eg: DDRA = 0x0F .. implies PA0-PA3 are output and PA4-PA7 are input
Eg: DDRA = 0xA0 .. implies PA0-PA4,PA6 are input and PA5,PA7 are output
PORT


PORT register is used to assign a state (High(1) or Low(0)) to a pin which has already been
indicated to be an output pin by DDR register.


Usage: PORTX=<value> . Where X is to replaced by either A or B or C or D

Eg: PORTA = 000 .. implies all 8 pins are giving LOW State

Eg: PORTA = 0xFF implies all 8 pins are giving HIGH State

Eg: PORTA = 0x0F .. implies PA0-PA3 are giving HIGH State and PA4-PA7 are giving
LOW State

Eg: PORTA = 0xA0 .. implies PA0-PA4,PA6 are giving LOW State and PA5,PA7 are
giving HIGH State
PIN


PIN register is used to read the state (High(1) or Low(0)) from a pin which has already been indicated to
be an input pin by DDR register.


Usage: PINX=<value> . Where X is to replaced by either A or B or C or D

Eg: PINA = 000 .. implies all 8 pins are receiving LOW State

Eg: PINA = 0xFF implies all 8 pins are receiving HIGH State

Eg: PINA = 0x0F .. implies PA0-PA3 are receiving HIGH Stateand PA4-PA7 are receiving LOW
State

Eg: PINA = 0xA0 .. implies PA0-PA4,PA6 are receiving LOW State and PA5,PA7 are receiving
HIGH State

You might also like