SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
1
01-General Purpose
Input/ Output
By : Mohamed Fawzy
Programming AVR Microcontrollers
© Mohamed F.A.B 2015
Lecture Notes:
2
© Mohamed F.A.B 2015
o Set Your Phone To Vibration Mode.
o Ask any time.
o During labs, Feel Free To Check Any Materials or
Internet.
o Slides are self content.
o Feel Free To Share This Materials With Your Friends.
o Work Hard For Achieving Most Benefits Of This Course.
3
Don't Forget !!!!
© Mohamed F.A.B 2015
Any Expert Was Once A Beginner

4
Agenda.
Lesson (4):
ATMEGA32 Overview and Main Hardware
Connections.
Lesson (5):
GPIO (General Purpose Input Output) Module.
© Mohamed F.A.B 2015
5
Lesson (4) Topics.
© Mohamed F.A.B 2015
Lesson (4):
ATMEGA32 Overview and Main Hardware Connections.
► Take a look in Datasheet.
► ATMEL Code Decoding.
► Main Hardware Connection.
6
ATMEL Code Decoder (OLD).
© Mohamed F.A.B 2015
AT-MEGA-8L-8PI
ATMEL
Family
Flash
Size
Low Power(2.7V)
FOSC
PDIP
I:industerial
C:comertial
M:martial
7
ATMEL Code Decoder (New).
© Mohamed F.A.B 2015
AT-MEGA-32A-Px
ATMEL
Family
Flash
Size
New
Generation
PU:PDIP
AU:SMD
8
Main Hardware Connections.
© Mohamed F.A.B 2015
 RESET.
 Power Pins (VCC,GND).
 FOSC (XTAL1,XTAL2).
9
Lesson (5)
© Mohamed F.A.B 2015
Lesson (5):
GPIO (General Purpose Input Output) Module.
10
Lesson (5) Topics.
© Mohamed F.A.B 2015
Lesson (5):
GPIO (General Purpose Input Output) Module.
► GPIO in ATMEGA32.
► Control GPIO in ATMEGA32.
► Interfacing LED with MC.
► Interfacing Switch with MC.
► Project (1) Password.
► Project(2) The Game.
11
ATMEGA32 GPIO.
© Mohamed F.A.B 2015
o ATMEGA32 has 32 GPIO Pin.
o ATMEGA32 has PORTs (PORTA,PORTB,PORTC,PORTD).
12
GPIO Characteristics in ATMEGA32.
© Mohamed F.A.B 2015
o General Purpose Input Output (GPIO).
o Bi-directional I/O s with internal Pull Up
Resistors.
o Push Pull Outputs ( Source or Sink for current).
o GPIOs are Grouped Into Ports Of Up to 8 Pins.
o Each IO Pin Has Two Protection Diodes.
13
I/O Equivalent Schematic.
© Mohamed F.A.B 2015
14
Control GPIO in ATMEGA32.
© Mohamed F.A.B 2015
o DDRx To define if PIN or PORT is Input or Output.
o PINxTo receive output from out world.
o PORTxTo set value to be out from MC.
15
Example (PORTA)-Datasheet Page 66
© Mohamed F.A.B 2015
16
Accessing I/O ports in CodeVision.
© Mohamed F.A.B 2015
 Controlling All PORT Pins:
 Controlling Single Pin:
DDRC=0xFF;
//configure all PORTC as output (Hexadecimal Format).
DDRC=0b11111111;
//configure all PORTC as output (Binary Format).
DDRC=255;
//configure all PORTC as output (Decimal Format).
PORTC=0xF0;
PORTC=0b11110000;
PORTC=240;
DDRC.0=1;
//configure PORTC0 pin as output.
DDRC.1=0;
//configure PORTC1 pin as input.
PORTC.0=1;
//outing logic 1 (5V) on PORTC0 Pin.
17
Interfacing LEDs with µC
© Mohamed F.A.B 2015
18
LED (Light Emitting Diode) .
© Mohamed F.A.B 2015
o LED stands for Light Emitting Diode.
o LED has a polarity.(Anode & Cathode).
o LED need almost 10mA and 3V to work.
19
Source & Sink Current.
© Mohamed F.A.B 2015
Source Current. Sink Current
NOTES:
 Source Current is better.
 At high current:
 Source: MC will hung up.
 Sink: MC will be damaged.
See Datasheet page 297 (Electrical Characteristics).
20
Interfacing LED with µC.
© Mohamed F.A.B 2015
Now, We need to design a circuit of
interfacing LED with µC.
 I led=10mA.
 Vled= 3V.
 V mc= 5V.
 𝑅 =
5−3
10 𝑚𝐴
=
2
10 𝑚𝐴
=200Ω.
 Typical R Value=220Ω or 330 Ω.
We need to connect LED to PORTC0 and blinking it every 500 ms.
Exercise (1).
Don't forget to include delay library header file.
#include <delay.h>
NOTE
21
Interfacing Buttons with µC
© Mohamed F.A.B 2015
22
Pull Up and Pull Down Resistors.
© Mohamed F.A.B 2015
Pull Up Resistor. Pull Down Resistor.
 Why use Pull Up and Pull Down.
 Why use R1?
 R1 between 4.7K Ω and 10K Ω.
 Why R1 10K Ω.
ATMEGA32 Has an Internal Pull Up Resistor.
NOTE
23
Switch bounce and de-bounce.
© Mohamed F.A.B 2015
o Switch De-Bounce
 Software Solution.
 Hardware Solution (RC Filter and schmitt Trigger).
We need to connect LED to PORTC0 and control it
using switch.
Exercise (2).
Predicted
True
24
Switch Key Click Vs. Key Press.
© Mohamed F.A.B 2015
EX:
If (sw is pressed)
{
delay_ms (250); //debounce delay & press wait
//statements
}
o Key Click: A Function For This Button Doesn't Be Executed Until You
Release Your Hand From The Button.
EX:
If (sw is pressed)
{
delay_ms (10); //debounce delay
//statements
while (sw is pressed); //still press do nothing
}
 Key Press: A Function Of This Key will be executed as soon as you press the
Button.
25
Projects.
© Mohamed F.A.B 2015
We need to connect LED on PORTC0 and three
buttons (PORTC1,PORTC2,PORTC3)
When I press button1 one time,button2 two times
and button3 three times, LED on PORTC0 turn ON
for 0.5 second.
Project (1) Password.
We need to connect 8LEDs on PORTC , 8LEDs on
PORTB and two buttons (PORTA0 and PORTA1)
[the two players].
Every press on button1 (PORTA0) increment
PORTC by 1 and Every press on button2 (PORTA1)
increment PORTB by 1 and first one reach 255 is
the winner.   
Project (2) The Game.
26
Motivation.
© Mohamed F.A.B 2015
We need to connect 5 LEDs to PORTD0 and Flashing it.
Exercise (3).   
Let's Know what is Wrong Next Lecture.
NOTE
27
Questions:
© Mohamed F.A.B 2015
Thank You All 
28
mo7amed.fawzy33@gmail.com
01006032792
fawzy.fab@gmail.com
© Mohamed F.A.B 2015

Mais conteúdo relacionado

Mais procurados (20)

Communication protocols - Embedded Systems
Communication protocols - Embedded SystemsCommunication protocols - Embedded Systems
Communication protocols - Embedded Systems
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
SPI Protocol in LPC2148
SPI  Protocol in LPC2148SPI  Protocol in LPC2148
SPI Protocol in LPC2148
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
8086 pin details
8086 pin details8086 pin details
8086 pin details
 
Basic interfacing of LEDs
Basic interfacing of LEDsBasic interfacing of LEDs
Basic interfacing of LEDs
 
Arduino- Serial communication
Arduino-  Serial communicationArduino-  Serial communication
Arduino- Serial communication
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
I2C introduction
I2C introductionI2C introduction
I2C introduction
 
PIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC InterfacingPIC Microcontroller | ADC Interfacing
PIC Microcontroller | ADC Interfacing
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Interfacing 8255
Interfacing 8255Interfacing 8255
Interfacing 8255
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
 
8259 Programmable Interrupt Controller
8259 Programmable Interrupt Controller8259 Programmable Interrupt Controller
8259 Programmable Interrupt Controller
 
Interrupts in pic
Interrupts in picInterrupts in pic
Interrupts in pic
 
What is JTAG?
What is JTAG?What is JTAG?
What is JTAG?
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
 

Destaque

04 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.201604 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.2016Mohamed Fawzy
 
06 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.201606 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.2016Mohamed Fawzy
 
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
AVR_Course_Day6 external hardware  interrupts and analogue to digital converterAVR_Course_Day6 external hardware  interrupts and analogue to digital converter
AVR_Course_Day6 external hardware interrupts and analogue to digital converterMohamed Ali
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programmingMohamed Ali
 
Regis Pneumatic - Solenoid Valve Quality Process Presentation
Regis Pneumatic - Solenoid Valve Quality Process PresentationRegis Pneumatic - Solenoid Valve Quality Process Presentation
Regis Pneumatic - Solenoid Valve Quality Process PresentationRegis-pneumatic
 
AVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfacesAVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfacesMohamed Ali
 
AVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcbAVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcbMohamed Ali
 
AVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerAVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerMohamed Ali
 
AVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniquesAVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniquesMohamed Ali
 
Introduction to Basic electronics
Introduction to Basic electronicsIntroduction to Basic electronics
Introduction to Basic electronicsMyrna Cabrera
 
AVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsAVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsMohamed Ali
 
AVR programming - BASICS
AVR programming - BASICSAVR programming - BASICS
AVR programming - BASICSRobotix 2011
 

Destaque (19)

water latching solenoid valve
water latching solenoid valvewater latching solenoid valve
water latching solenoid valve
 
04 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.201604 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.2016
 
06 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.201606 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.2016
 
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
AVR_Course_Day6 external hardware  interrupts and analogue to digital converterAVR_Course_Day6 external hardware  interrupts and analogue to digital converter
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
 
Catia introduccionv5
Catia introduccionv5Catia introduccionv5
Catia introduccionv5
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programming
 
Regis Pneumatic - Solenoid Valve Quality Process Presentation
Regis Pneumatic - Solenoid Valve Quality Process PresentationRegis Pneumatic - Solenoid Valve Quality Process Presentation
Regis Pneumatic - Solenoid Valve Quality Process Presentation
 
AVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfacesAVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfaces
 
AVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcbAVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcb
 
AVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontrollerAVR_Course_Day4 introduction to microcontroller
AVR_Course_Day4 introduction to microcontroller
 
AVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniquesAVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniques
 
Catia v5 NOTES
Catia v5  NOTESCatia v5  NOTES
Catia v5 NOTES
 
Introduction to Basic electronics
Introduction to Basic electronicsIntroduction to Basic electronics
Introduction to Basic electronics
 
BASIC ELECTRONICS
BASIC ELECTRONICS BASIC ELECTRONICS
BASIC ELECTRONICS
 
AVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsAVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronics
 
Z:\catia v5
Z:\catia v5Z:\catia v5
Z:\catia v5
 
Electronics ppt
Electronics ppt Electronics ppt
Electronics ppt
 
AVR ATmega32
AVR ATmega32AVR ATmega32
AVR ATmega32
 
AVR programming - BASICS
AVR programming - BASICSAVR programming - BASICS
AVR programming - BASICS
 

Semelhante a 01 GPIO||General Purpose Input Output.2016

LED HD VIDEO PROCESSOR USER’S MANUAL
LED HD VIDEO PROCESSOR USER’S MANUALLED HD VIDEO PROCESSOR USER’S MANUAL
LED HD VIDEO PROCESSOR USER’S MANUALMax Dan
 
Etapes fab-venti-v2
Etapes fab-venti-v2Etapes fab-venti-v2
Etapes fab-venti-v2Jonah Marrs
 
07 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).201607 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).2016Mohamed Fawzy
 
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAVHOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAVGIRISH HARMUKH
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5StackMasawo Yamazaki
 
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
eece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docxeece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docx
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docxSALU18
 
Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Moayadhn
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manualtwinkleratna
 
00 let us get started.2016
00 let us get started.201600 let us get started.2016
00 let us get started.2016Mohamed Fawzy
 
Power the world with mbed LPC1768
Power the world with mbed LPC1768Power the world with mbed LPC1768
Power the world with mbed LPC1768yoonghm
 
Vista 1600 c epon olt quick start manual(r1.2)
Vista 1600 c epon olt quick start manual(r1.2)Vista 1600 c epon olt quick start manual(r1.2)
Vista 1600 c epon olt quick start manual(r1.2)Shanxi Cai
 
Microcontroller 8051 training
Microcontroller 8051 trainingMicrocontroller 8051 training
Microcontroller 8051 trainingPradip Bhandari
 
JVL Servo/Step Motor Indexers SMI30 and SMI31
JVL Servo/Step Motor Indexers SMI30 and SMI31JVL Servo/Step Motor Indexers SMI30 and SMI31
JVL Servo/Step Motor Indexers SMI30 and SMI31Electromate
 
Advanced motion controls dx15co8 src
Advanced motion controls dx15co8 srcAdvanced motion controls dx15co8 src
Advanced motion controls dx15co8 srcElectromate
 
Advanced motion controls dx15co8
Advanced motion controls dx15co8Advanced motion controls dx15co8
Advanced motion controls dx15co8Electromate
 
F5 m instruction manual
F5 m instruction manualF5 m instruction manual
F5 m instruction manualToàn Huỳnh
 
5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) Datasheet5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) DatasheetPanox Display
 
1.39 inch Round Amoled(400x400) Datasheet
1.39 inch Round Amoled(400x400) Datasheet1.39 inch Round Amoled(400x400) Datasheet
1.39 inch Round Amoled(400x400) DatasheetPanox Display
 

Semelhante a 01 GPIO||General Purpose Input Output.2016 (20)

LED HD VIDEO PROCESSOR USER’S MANUAL
LED HD VIDEO PROCESSOR USER’S MANUALLED HD VIDEO PROCESSOR USER’S MANUAL
LED HD VIDEO PROCESSOR USER’S MANUAL
 
Etapes fab-venti-v2
Etapes fab-venti-v2Etapes fab-venti-v2
Etapes fab-venti-v2
 
07 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).201607 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).2016
 
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAVHOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
 
I made some more expansion board for M5Stack
I made some more expansion  board for M5StackI made some more expansion  board for M5Stack
I made some more expansion board for M5Stack
 
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
eece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docxeece237lab2EECE237Lab2.uvproj    1.1   ### uVision .docx
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
 
Intro2 Robotic With Pic18
Intro2 Robotic With Pic18Intro2 Robotic With Pic18
Intro2 Robotic With Pic18
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 
00 let us get started.2016
00 let us get started.201600 let us get started.2016
00 let us get started.2016
 
presentation_28 (1).pptx
presentation_28 (1).pptxpresentation_28 (1).pptx
presentation_28 (1).pptx
 
Módulo adc 18f4550
Módulo adc   18f4550Módulo adc   18f4550
Módulo adc 18f4550
 
Power the world with mbed LPC1768
Power the world with mbed LPC1768Power the world with mbed LPC1768
Power the world with mbed LPC1768
 
Vista 1600 c epon olt quick start manual(r1.2)
Vista 1600 c epon olt quick start manual(r1.2)Vista 1600 c epon olt quick start manual(r1.2)
Vista 1600 c epon olt quick start manual(r1.2)
 
Microcontroller 8051 training
Microcontroller 8051 trainingMicrocontroller 8051 training
Microcontroller 8051 training
 
JVL Servo/Step Motor Indexers SMI30 and SMI31
JVL Servo/Step Motor Indexers SMI30 and SMI31JVL Servo/Step Motor Indexers SMI30 and SMI31
JVL Servo/Step Motor Indexers SMI30 and SMI31
 
Advanced motion controls dx15co8 src
Advanced motion controls dx15co8 srcAdvanced motion controls dx15co8 src
Advanced motion controls dx15co8 src
 
Advanced motion controls dx15co8
Advanced motion controls dx15co8Advanced motion controls dx15co8
Advanced motion controls dx15co8
 
F5 m instruction manual
F5 m instruction manualF5 m instruction manual
F5 m instruction manual
 
5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) Datasheet5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) Datasheet
 
1.39 inch Round Amoled(400x400) Datasheet
1.39 inch Round Amoled(400x400) Datasheet1.39 inch Round Amoled(400x400) Datasheet
1.39 inch Round Amoled(400x400) Datasheet
 

Mais de Mohamed Fawzy

05 EEPROM memory.2016
05 EEPROM memory.201605 EEPROM memory.2016
05 EEPROM memory.2016Mohamed Fawzy
 
02 Interfacing High Power Devices.2016
02 Interfacing High Power Devices.201602 Interfacing High Power Devices.2016
02 Interfacing High Power Devices.2016Mohamed Fawzy
 
أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!Mohamed Fawzy
 
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.Mohamed Fawzy
 
C programming day#3.
C programming day#3.C programming day#3.
C programming day#3.Mohamed Fawzy
 

Mais de Mohamed Fawzy (8)

05 EEPROM memory.2016
05 EEPROM memory.201605 EEPROM memory.2016
05 EEPROM memory.2016
 
02 Interfacing High Power Devices.2016
02 Interfacing High Power Devices.201602 Interfacing High Power Devices.2016
02 Interfacing High Power Devices.2016
 
أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!
 
Ce from a to z
Ce from a to zCe from a to z
Ce from a to z
 
Taqa
TaqaTaqa
Taqa
 
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.
 
C programming day#3.
C programming day#3.C programming day#3.
C programming day#3.
 
C programming day#1
C programming day#1C programming day#1
C programming day#1
 

Último

Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSsandhya757531
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfNainaShrivastava14
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsapna80328
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESkarthi keyan
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 

Último (20)

Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveying
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 

01 GPIO||General Purpose Input Output.2016

  • 1. 1 01-General Purpose Input/ Output By : Mohamed Fawzy Programming AVR Microcontrollers © Mohamed F.A.B 2015
  • 2. Lecture Notes: 2 © Mohamed F.A.B 2015 o Set Your Phone To Vibration Mode. o Ask any time. o During labs, Feel Free To Check Any Materials or Internet. o Slides are self content. o Feel Free To Share This Materials With Your Friends. o Work Hard For Achieving Most Benefits Of This Course.
  • 3. 3 Don't Forget !!!! © Mohamed F.A.B 2015 Any Expert Was Once A Beginner 
  • 4. 4 Agenda. Lesson (4): ATMEGA32 Overview and Main Hardware Connections. Lesson (5): GPIO (General Purpose Input Output) Module. © Mohamed F.A.B 2015
  • 5. 5 Lesson (4) Topics. © Mohamed F.A.B 2015 Lesson (4): ATMEGA32 Overview and Main Hardware Connections. ► Take a look in Datasheet. ► ATMEL Code Decoding. ► Main Hardware Connection.
  • 6. 6 ATMEL Code Decoder (OLD). © Mohamed F.A.B 2015 AT-MEGA-8L-8PI ATMEL Family Flash Size Low Power(2.7V) FOSC PDIP I:industerial C:comertial M:martial
  • 7. 7 ATMEL Code Decoder (New). © Mohamed F.A.B 2015 AT-MEGA-32A-Px ATMEL Family Flash Size New Generation PU:PDIP AU:SMD
  • 8. 8 Main Hardware Connections. © Mohamed F.A.B 2015  RESET.  Power Pins (VCC,GND).  FOSC (XTAL1,XTAL2).
  • 9. 9 Lesson (5) © Mohamed F.A.B 2015 Lesson (5): GPIO (General Purpose Input Output) Module.
  • 10. 10 Lesson (5) Topics. © Mohamed F.A.B 2015 Lesson (5): GPIO (General Purpose Input Output) Module. ► GPIO in ATMEGA32. ► Control GPIO in ATMEGA32. ► Interfacing LED with MC. ► Interfacing Switch with MC. ► Project (1) Password. ► Project(2) The Game.
  • 11. 11 ATMEGA32 GPIO. © Mohamed F.A.B 2015 o ATMEGA32 has 32 GPIO Pin. o ATMEGA32 has PORTs (PORTA,PORTB,PORTC,PORTD).
  • 12. 12 GPIO Characteristics in ATMEGA32. © Mohamed F.A.B 2015 o General Purpose Input Output (GPIO). o Bi-directional I/O s with internal Pull Up Resistors. o Push Pull Outputs ( Source or Sink for current). o GPIOs are Grouped Into Ports Of Up to 8 Pins. o Each IO Pin Has Two Protection Diodes.
  • 13. 13 I/O Equivalent Schematic. © Mohamed F.A.B 2015
  • 14. 14 Control GPIO in ATMEGA32. © Mohamed F.A.B 2015 o DDRx To define if PIN or PORT is Input or Output. o PINxTo receive output from out world. o PORTxTo set value to be out from MC.
  • 15. 15 Example (PORTA)-Datasheet Page 66 © Mohamed F.A.B 2015
  • 16. 16 Accessing I/O ports in CodeVision. © Mohamed F.A.B 2015  Controlling All PORT Pins:  Controlling Single Pin: DDRC=0xFF; //configure all PORTC as output (Hexadecimal Format). DDRC=0b11111111; //configure all PORTC as output (Binary Format). DDRC=255; //configure all PORTC as output (Decimal Format). PORTC=0xF0; PORTC=0b11110000; PORTC=240; DDRC.0=1; //configure PORTC0 pin as output. DDRC.1=0; //configure PORTC1 pin as input. PORTC.0=1; //outing logic 1 (5V) on PORTC0 Pin.
  • 17. 17 Interfacing LEDs with µC © Mohamed F.A.B 2015
  • 18. 18 LED (Light Emitting Diode) . © Mohamed F.A.B 2015 o LED stands for Light Emitting Diode. o LED has a polarity.(Anode & Cathode). o LED need almost 10mA and 3V to work.
  • 19. 19 Source & Sink Current. © Mohamed F.A.B 2015 Source Current. Sink Current NOTES:  Source Current is better.  At high current:  Source: MC will hung up.  Sink: MC will be damaged. See Datasheet page 297 (Electrical Characteristics).
  • 20. 20 Interfacing LED with µC. © Mohamed F.A.B 2015 Now, We need to design a circuit of interfacing LED with µC.  I led=10mA.  Vled= 3V.  V mc= 5V.  𝑅 = 5−3 10 𝑚𝐴 = 2 10 𝑚𝐴 =200Ω.  Typical R Value=220Ω or 330 Ω. We need to connect LED to PORTC0 and blinking it every 500 ms. Exercise (1). Don't forget to include delay library header file. #include <delay.h> NOTE
  • 21. 21 Interfacing Buttons with µC © Mohamed F.A.B 2015
  • 22. 22 Pull Up and Pull Down Resistors. © Mohamed F.A.B 2015 Pull Up Resistor. Pull Down Resistor.  Why use Pull Up and Pull Down.  Why use R1?  R1 between 4.7K Ω and 10K Ω.  Why R1 10K Ω. ATMEGA32 Has an Internal Pull Up Resistor. NOTE
  • 23. 23 Switch bounce and de-bounce. © Mohamed F.A.B 2015 o Switch De-Bounce  Software Solution.  Hardware Solution (RC Filter and schmitt Trigger). We need to connect LED to PORTC0 and control it using switch. Exercise (2). Predicted True
  • 24. 24 Switch Key Click Vs. Key Press. © Mohamed F.A.B 2015 EX: If (sw is pressed) { delay_ms (250); //debounce delay & press wait //statements } o Key Click: A Function For This Button Doesn't Be Executed Until You Release Your Hand From The Button. EX: If (sw is pressed) { delay_ms (10); //debounce delay //statements while (sw is pressed); //still press do nothing }  Key Press: A Function Of This Key will be executed as soon as you press the Button.
  • 25. 25 Projects. © Mohamed F.A.B 2015 We need to connect LED on PORTC0 and three buttons (PORTC1,PORTC2,PORTC3) When I press button1 one time,button2 two times and button3 three times, LED on PORTC0 turn ON for 0.5 second. Project (1) Password. We need to connect 8LEDs on PORTC , 8LEDs on PORTB and two buttons (PORTA0 and PORTA1) [the two players]. Every press on button1 (PORTA0) increment PORTC by 1 and Every press on button2 (PORTA1) increment PORTB by 1 and first one reach 255 is the winner.    Project (2) The Game.
  • 26. 26 Motivation. © Mohamed F.A.B 2015 We need to connect 5 LEDs to PORTD0 and Flashing it. Exercise (3).    Let's Know what is Wrong Next Lecture. NOTE
  • 28. Thank You All  28 mo7amed.fawzy33@gmail.com 01006032792 fawzy.fab@gmail.com © Mohamed F.A.B 2015