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

Programmable peripheral interface 8255
Programmable peripheral interface 8255Programmable peripheral interface 8255
Programmable peripheral interface 8255Marajulislam3
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdfSrikrishna Thota
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051ssuser3a47cb
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureDominicHendry
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontrollerthokalpv
 
Analog to Digital converter in ARM
Analog to Digital converter in ARMAnalog to Digital converter in ARM
Analog to Digital converter in ARMAarav Soni
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly languageMir Majid
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarSAQUIB AHMAD
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Urvashi Singh
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.pptDr.YNM
 
Arduino and its hw architecture
Arduino and its hw architectureArduino and its hw architecture
Arduino and its hw architectureZeeshan Rafiq
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
8259 Programmable Interrupt Controller by vijay
8259 Programmable Interrupt Controller by vijay8259 Programmable Interrupt Controller by vijay
8259 Programmable Interrupt Controller by vijayVijay Kumar
 
23. serial and parallel data communication
23. serial and parallel data communication23. serial and parallel data communication
23. serial and parallel data communicationsandip das
 

Mais procurados (20)

I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Programmable peripheral interface 8255
Programmable peripheral interface 8255Programmable peripheral interface 8255
Programmable peripheral interface 8255
 
UART
UARTUART
UART
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
Analog to Digital converter in ARM
Analog to Digital converter in ARMAnalog to Digital converter in ARM
Analog to Digital converter in ARM
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Pentium processor
Pentium processorPentium processor
Pentium processor
 
Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
Arduino and its hw architecture
Arduino and its hw architectureArduino and its hw architecture
Arduino and its hw architecture
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
8259 Programmable Interrupt Controller by vijay
8259 Programmable Interrupt Controller by vijay8259 Programmable Interrupt Controller by vijay
8259 Programmable Interrupt Controller by vijay
 
23. serial and parallel data communication
23. serial and parallel data communication23. serial and parallel data communication
23. serial and parallel data communication
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 

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
 
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
 
CONPROSYS Product Training(Taiwan)
CONPROSYS Product Training(Taiwan)CONPROSYS Product Training(Taiwan)
CONPROSYS Product Training(Taiwan)Jimmy Hsu
 
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
 
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
 
CONPROSYS Product Training(Taiwan)
CONPROSYS Product Training(Taiwan)CONPROSYS Product Training(Taiwan)
CONPROSYS Product Training(Taiwan)
 
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
 
00 let us get started.2016
00 let us get started.201600 let us get started.2016
00 let us get started.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 (9)

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
 
00 let us get started.2016
00 let us get started.201600 let us get started.2016
00 let us get started.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

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 

Último (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 

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