Download presentation
Presentation is loading. Please wait.
1
AVR I/O Port Programming
Presentation by:- kanojeeya pathik v. ( ) (4121) Guided by:- Prof. A.J.Mankad Department of electronics and communication Shantilal shah engineering collage Bhavnagar
2
outline AT Mega 32 pin diagram ATMega32 Pin out & Descriptions
Configuration of port Alternate functions of ports
3
AT Mega 32 pin diagram Port B Port A Port C Port D
4
ATMega32 Pin out & Descriptions
5
Port description
6
ATMega32 Pin out & Descriptions
7
Configuration of port This is very important point of port programming. You have to configure the port as either input port or output pot. The DDRx will help us to define the directions of port. We can configure each and every pin of all of 4 ports either input or output individually. For configurations of port we need to understand the importance and construction of DDRx.
8
Defining a pin as either Input or Output – The DDRx Registers
9
How it configured
10
Cont… Pull-up resistors are used in electronic logic circuits to ensure that inputs to logic systems settle at expected logic levels if external devices are disconnected or high-impedance
11
Cont… Simply the DDRx works as a tri-state buffer, as shown in above figure when DDRx has zero value at that time the ports works for input, at that time the pull up registers managed by PORTx registers. And hence the on the external pins are copied into the PINx register located in SFR memory. When the DDRx have one or high value at that time the pull up registers are connected to the external pins and hence the data stored in PORTx register goes at external pins. The DDRx, PORTx, PINx are located in SFR memory of microcontroller, each port has its own and separate registers.
12
PINx PINx is a simple register located at SFR memory region.
It always remind that we used the PINx register to copy the data from port to the PIN register, to process it we have to take this data into some another register from R0 to R31. IN instruction is used to copy data from PIN register to another register.
13
PORTx As the PINx register is used to input the data, this is used to output data from registers to in ports. This also a simple register which is located into SFR The OUT instruction is used to copy data of PORT register on the port pins. For ex. To out the data of R16 on port B after the configuration the program is like this Out PORTB,R16
14
Alternate functions of ports
As we know the all ports provides multiple functions. The main or primary function is I/O, but using overriding signals we can put them to work some other function like serial communication etc. All port and all pins of every ports provide dual functions.
15
Cont…
16
Cont…
17
Overriding of signals
18
Cont… Note: 1. WPx, WDx, RRx, RPx, and RDx are common to all pins within the same port. clkI/O, SLEEP, and PUD are common to all ports. All other signals are unique for each pin.
19
Single pin accessing
20
example
21
Cont…
22
references Universiti teknologi Malaysia (www.utm.my)
Avr AT Mega 32 datasheet Avr microcontroller and embedded system using assembly and c by mazidi
23
Thank you
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.