The ATmega16-A has 40 pins ,only 32 pins serve as I/O ports and the other 8 pins is :VCC,AVCC,2xGND,AREF,RESET,XTAL1 and XTAL2.
Pin Descriptions:
1-VCC: Digital supply voltage. 2-GND: Ground.
3-AVCC: is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.
4-AREF: is the analog reference pin for the A/D Converter.
5-XTAL1: Input to the inverting Oscillator amplifier and input to the internal clock operating circuit.
6-XTAL2: Output from the inverting Oscillator amplifier.
7-RESET: A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. 8-Port A (PA7:PA0):
Port A serves as the analog inputs to the A/D Converter.
Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins can provide internal pull-up resistors (selected for each bit).
9-Port B (PB7:PB0):
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
Port B also serves the functions of various special features of the ATmega16A as listed on table below:
10-Port C (PC7:PC0):
Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
Port C also serves the functions of the JTAG interface and other special features of the ATmega16A as listed on table below:
11-Port D (DDC7:DDC0):
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
Port D also serves the functions of various special features of the ATmega16A as listed on table below:
PORT SYSTEM:
The Atmel ATmega16 is equipped with four 8-bit general-purpose, digital I/O ports designated PORTA, PORTB, PORTC, and PORTD.
For basic digital I/O port feature each port has three registers associated with it:
1-Data Register (PORTx): used to write output data to the port.
2-Data Direction Register (DDCRx): used to set a specific port pin to either output (1) or Input (0).
3-Input Pin Address (PINx): used to read input data from the port.
Note: AVR Studio6.1 is the compiler used in these Tutorials. These are some examples for how to handle I/O Ports:
We can use Binary or Hexadecimal number system to set the Bits in different registers.
1- DDRC Port C Data Direction Register Data direction Input or Output: