Javatpoint Logo
Javatpoint Logo

AVR I/O Port Programming

In AVR microcontroller family, there are many ports available for I/O operations, depending on which family microcontroller you choose. For the ATmega32 40-pin chip 32 Pins are available for I/O operation. The four ports PORTA, PORTB, PORTC, and PORTD are programmed for performing desired operation.

The Pin diagram of ATmega32 microcontroller is shown below:

AVR I/O Port Programming1

The number of ports in AVR family varies depending on number of pins available on chip. The 8-pin AVR has port B only, while the 64-pin version has ports A to ports F, and the 100-pin AVR has ports A to ports L.

The table showing Numbers of ports in some AVR family members is shown below:

AVR I/O Port Programming2

Note: X indicates that the port is available.

The 40-pin AVR has four ports for using any of the ports as an input or output port, it must be accordingly programmed. In AVR microcontroller not all ports have 8 pins. For example:-in the ATmega8, Port C has 7 pins.

The Registers Addresses for ATmega32 Ports is given below:

AVR I/O Port Programming3

Each port in AVR microcontroller has three I/O registers associated with it. They are designated as PORTx, DDRx and PINx. For example: - in case of Port B we have PORTB, DDRB, and PINB. Here DDR stands for Data Direction Registers, and PIN stands for Port Input pins.

Each of I/O registers is 8 bits wide, and each port has a maximum of 8 pins, therefore each bit of I/O registers affects one of the pins.

For accessing I/O registers associated with the ports the common relationship between the registers and the pins of AVR microcontroller is used.

The relation between the Registers and the Pins of AVR is shown below:

AVR I/O Port Programming4
Next TopicAVR Registers

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials

B.Tech / MCA