SlideShare ist ein Scribd-Unternehmen logo
1 von 20
I/O PORTS
Prepared by:

Islam Samir
AGENDA




I/O ports and how to use them
Some exceptions with some ports.
Handling the bouncing problem.
AGENDA




I/O ports and how to use them
Some exceptions with some ports.
Handling the bouncing problem.
I/O PORTS


Every microcontroller must have means of communication to the
outside world.



The simplest way for communication is using general purpose I/O
ports.
I/O PORTS


Reading a port:

- Means reading the status (voltage level) present on the

-

pin.
Writing to a port:
Means writing to the port latches.

- You have to determine the direction of the I/O pin before
using it, this is done by changing the value of the TRIS
register.
I/O PORTS
Example on reading a port
If the voltages: 0.5v, 4v, 2v were present on three different pins.
If you read these pins, you’ll get the digital logic value
corresponds to each voltage level  0 1 0.
Considering the range of ‘0’ : 0v  2.5v
the range of ‘1’ : 2.5v  5v
I/O PORTS


The I/O pin direction is controlled by a register called TRIS.
PORT<x> is controlled by the register TRIS<x>.



If you write ‘1’ in a bit in TRIS<x> register, this means that the
corresponding bit in PORT<x> is input.



A ‘0’ means  output.
I/O PORTS
HOW?
 Setting a bit in the TRIS<x> register puts the
corresponding output driver in a high-impedance input
mode (O/P mode is off).


Clearing a bit in the TRISB register puts the contents of
the output latch on the selected pin(s). (O/P mode is on)



I/O ports are multiplexed with other peripherals, if these
peripherals were used you won’t use the pin as I/O pin.
I/O PORTS


Notes:

1)

If port pins are multiplexed with analog peripherals, you must select
the function of them to be analog input or digital I/O, you do so by
changing the value of ADCON1 register.

2)

For analog inputs, make the corresponding TRIS 1.
I/O PORTS
3)
-

-

Each of the PORTB pins has a weak internal pull-up resistors.
A single control bit can turn on all the pull-ups. This is performed by
clearing bit RBPU (OPTION_REG<7>).
The weak pull-up is automatically turned off when the port pin is
configured as an output.
I/O PORTS
4)

RA4 pin is "Open-Drain" type
output pin. This means it cannot
source current and it will be high
impedance when assigned logic '1'
to it.
- You cannot set this pin as an output
pin by only using 'TRISA=0x00'.
The solution is attaching a pull up
resistor (10K) to the RA4 pin in
order to use this pin as an output
pin.
SWITCHES


We use switches to give an order to the MCU to do
something by changing the voltage level applied on
an I/O pin (input).
SWITCHES

-

Bouncing problem:
The problem with using a mechanical switch is that switch
contacts "bounce“ when you close the switch.
SWITCHES
-

-

-

When the switch is closed, the two contacts actually separate
and reconnect, typically 10 to 100 times in about 100ms.
This bouncing would send multiple key press signals to the
MCU which is not what you want.

While 100 milliseconds is quite short for us as humans, it is
actually quite long for a digital circuit and the period between
spikes is often enough for the application to respond.
SWITCHES
Solution:
1-Using RC circuit:
- We use it as a LPF, as the ripples
happen very fast (high frequency).

2-By software:
- By reading the value of the pin more than one time in small
time intervals to make sure of the real value on the pin.
-

This done by testing the value, wait for some time (110 ms)
and test again if the value is the same, so it’s the true value.
LEDS


It’s the simplest way to indicate an
output.



We have to use a current limiting
resistor with it (typically 330Ω).
APPLICATION 1
-

Write a program outputs high on RC0, if RB0 is low using
switches and leds.
ASSIGNMENT
-

Write a code for a MCU that outputs these results on PORTC<5:7>
for the inputs entered on PORTB<3:5>.

 Write a function that handles the bouncing problem.
PORTB (input)

PORTC (output)

000

010

001

110

010

011

001

001

Weitere ähnliche Inhalte

Was ist angesagt?

PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.parthi_arjun
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarGauravRaikar3
 
Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessorAMAN SRIVASTAVA
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Dhaval Kaneria
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051hello_priti
 
PIC-18 Microcontroller
PIC-18 MicrocontrollerPIC-18 Microcontroller
PIC-18 MicrocontrollerASHISH RANJAN
 
PPT on 8085 Microprocessor
PPT on 8085 Microprocessor  PPT on 8085 Microprocessor
PPT on 8085 Microprocessor DebrajJana4
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.pptDr.YNM
 
ATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part IATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part IVineethMP2
 
Microcontroller presentation
Microcontroller presentationMicrocontroller presentation
Microcontroller presentationxavierpaulino
 
Interrupts for PIC18
Interrupts for PIC18Interrupts for PIC18
Interrupts for PIC18raosandy11
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerSudhanshu Janwadkar
 
microcontroller basics
microcontroller basicsmicrocontroller basics
microcontroller basicssagar Ramdev
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and CountersShreyans Pathak
 
Microcontoller and Embedded System
Microcontoller and Embedded SystemMicrocontoller and Embedded System
Microcontoller and Embedded SystemKaran Thakkar
 

Was ist angesagt? (20)

8251 USART
8251 USART8251 USART
8251 USART
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikar
 
8279 PKDI
8279 PKDI8279 PKDI
8279 PKDI
 
Embedded c
Embedded cEmbedded c
Embedded c
 
Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessor
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
PIC-18 Microcontroller
PIC-18 MicrocontrollerPIC-18 Microcontroller
PIC-18 Microcontroller
 
Control Memory
Control MemoryControl Memory
Control Memory
 
PPT on 8085 Microprocessor
PPT on 8085 Microprocessor  PPT on 8085 Microprocessor
PPT on 8085 Microprocessor
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 
ATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part IATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part I
 
Microcontroller presentation
Microcontroller presentationMicrocontroller presentation
Microcontroller presentation
 
Interrupts for PIC18
Interrupts for PIC18Interrupts for PIC18
Interrupts for PIC18
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 
microcontroller basics
microcontroller basicsmicrocontroller basics
microcontroller basics
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and Counters
 
Microcontoller and Embedded System
Microcontoller and Embedded SystemMicrocontoller and Embedded System
Microcontoller and Embedded System
 

Andere mochten auch

8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O portsanishgoel
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog worldIslam Samir
 
Introduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIntroduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIslam Samir
 

Andere mochten auch (7)

8051 ram org
8051 ram org8051 ram org
8051 ram org
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O ports
 
Timers
TimersTimers
Timers
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog world
 
Interrupts
InterruptsInterrupts
Interrupts
 
Introduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIntroduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and Microcontrollers
 
USART
USARTUSART
USART
 

Ähnlich wie I/O Ports

An Overview Study on I/O Expander with I2C and SMBus Interface
An Overview Study on I/O Expander with I2C and SMBus InterfaceAn Overview Study on I/O Expander with I2C and SMBus Interface
An Overview Study on I/O Expander with I2C and SMBus InterfacePremier Farnell
 
8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.pptnotagain0712
 
Pin configuration of 8085
Pin configuration of 8085Pin configuration of 8085
Pin configuration of 808582338476
 
An alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdfAn alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdfleventhalbrad49439
 
To study the relay operation from digital control signal using LabVIEW.
To study the relay operation from digital control signal using LabVIEW.To study the relay operation from digital control signal using LabVIEW.
To study the relay operation from digital control signal using LabVIEW.Ankita Tiwari
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontrollerthokalpv
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]akmalKhan55
 
MICROPROCESSOR AND INTERFACING
MICROPROCESSOR AND INTERFACING MICROPROCESSOR AND INTERFACING
MICROPROCESSOR AND INTERFACING Radhika Talaviya
 
Introduction to arduino!
Introduction to arduino!Introduction to arduino!
Introduction to arduino!Makers of India
 
Automatic doorbell with object detection
Automatic doorbell with object detectionAutomatic doorbell with object detection
Automatic doorbell with object detectionAnurag Alaria
 
08 chapter03 06_status_bits_otl_otu_scan_logic_fa16
08 chapter03 06_status_bits_otl_otu_scan_logic_fa1608 chapter03 06_status_bits_otl_otu_scan_logic_fa16
08 chapter03 06_status_bits_otl_otu_scan_logic_fa16John Todora
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVRMohamed Abdallah
 

Ähnlich wie I/O Ports (20)

An Overview Study on I/O Expander with I2C and SMBus Interface
An Overview Study on I/O Expander with I2C and SMBus InterfaceAn Overview Study on I/O Expander with I2C and SMBus Interface
An Overview Study on I/O Expander with I2C and SMBus Interface
 
8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt
 
Pin configuration of 8085
Pin configuration of 8085Pin configuration of 8085
Pin configuration of 8085
 
An alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdfAn alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdf
 
K 36 rev-l
K 36 rev-lK 36 rev-l
K 36 rev-l
 
To study the relay operation from digital control signal using LabVIEW.
To study the relay operation from digital control signal using LabVIEW.To study the relay operation from digital control signal using LabVIEW.
To study the relay operation from digital control signal using LabVIEW.
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
Pin 8085
Pin 8085Pin 8085
Pin 8085
 
Introduction to PIC.pptx
Introduction to PIC.pptxIntroduction to PIC.pptx
Introduction to PIC.pptx
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
 
MICROPROCESSOR AND INTERFACING
MICROPROCESSOR AND INTERFACING MICROPROCESSOR AND INTERFACING
MICROPROCESSOR AND INTERFACING
 
8051 book
8051 book8051 book
8051 book
 
embedded system
embedded system  embedded system
embedded system
 
Introduction to arduino!
Introduction to arduino!Introduction to arduino!
Introduction to arduino!
 
Automatic doorbell with object detection
Automatic doorbell with object detectionAutomatic doorbell with object detection
Automatic doorbell with object detection
 
INTELIGENT RAILWAY SYSTEM
INTELIGENT RAILWAY SYSTEMINTELIGENT RAILWAY SYSTEM
INTELIGENT RAILWAY SYSTEM
 
Arduino intro.pptx
Arduino intro.pptxArduino intro.pptx
Arduino intro.pptx
 
Logic Gates & Family.pdf
Logic Gates & Family.pdfLogic Gates & Family.pdf
Logic Gates & Family.pdf
 
08 chapter03 06_status_bits_otl_otu_scan_logic_fa16
08 chapter03 06_status_bits_otl_otu_scan_logic_fa1608 chapter03 06_status_bits_otl_otu_scan_logic_fa16
08 chapter03 06_status_bits_otl_otu_scan_logic_fa16
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVR
 

Kürzlich hochgeladen

BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...noida100girls
 
DEPED Work From Home WORKWEEK-PLAN.docx
DEPED Work From Home  WORKWEEK-PLAN.docxDEPED Work From Home  WORKWEEK-PLAN.docx
DEPED Work From Home WORKWEEK-PLAN.docxRodelinaLaud
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfPaul Menig
 
Catalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdf
Catalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdfCatalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdf
Catalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdfOrient Homes
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyEthan lee
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst SummitHolger Mueller
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Roland Driesen
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Roomdivyansh0kumar0
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechNewman George Leech
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessAggregage
 

Kürzlich hochgeladen (20)

Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
 
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
 
DEPED Work From Home WORKWEEK-PLAN.docx
DEPED Work From Home  WORKWEEK-PLAN.docxDEPED Work From Home  WORKWEEK-PLAN.docx
DEPED Work From Home WORKWEEK-PLAN.docx
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
Catalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdf
Catalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdfCatalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdf
Catalogue ONG NƯỚC uPVC - HDPE DE NHAT.pdf
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst Summit
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman Leech
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for Success
 

I/O Ports

  • 2. AGENDA    I/O ports and how to use them Some exceptions with some ports. Handling the bouncing problem.
  • 3. AGENDA    I/O ports and how to use them Some exceptions with some ports. Handling the bouncing problem.
  • 4.
  • 5. I/O PORTS  Every microcontroller must have means of communication to the outside world.  The simplest way for communication is using general purpose I/O ports.
  • 6. I/O PORTS  Reading a port: - Means reading the status (voltage level) present on the  - pin. Writing to a port: Means writing to the port latches. - You have to determine the direction of the I/O pin before using it, this is done by changing the value of the TRIS register.
  • 7. I/O PORTS Example on reading a port If the voltages: 0.5v, 4v, 2v were present on three different pins. If you read these pins, you’ll get the digital logic value corresponds to each voltage level  0 1 0. Considering the range of ‘0’ : 0v  2.5v the range of ‘1’ : 2.5v  5v
  • 8. I/O PORTS  The I/O pin direction is controlled by a register called TRIS. PORT<x> is controlled by the register TRIS<x>.  If you write ‘1’ in a bit in TRIS<x> register, this means that the corresponding bit in PORT<x> is input.  A ‘0’ means  output.
  • 9. I/O PORTS HOW?  Setting a bit in the TRIS<x> register puts the corresponding output driver in a high-impedance input mode (O/P mode is off).  Clearing a bit in the TRISB register puts the contents of the output latch on the selected pin(s). (O/P mode is on)  I/O ports are multiplexed with other peripherals, if these peripherals were used you won’t use the pin as I/O pin.
  • 10.
  • 11. I/O PORTS  Notes: 1) If port pins are multiplexed with analog peripherals, you must select the function of them to be analog input or digital I/O, you do so by changing the value of ADCON1 register. 2) For analog inputs, make the corresponding TRIS 1.
  • 12. I/O PORTS 3) - - Each of the PORTB pins has a weak internal pull-up resistors. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU (OPTION_REG<7>). The weak pull-up is automatically turned off when the port pin is configured as an output.
  • 13. I/O PORTS 4) RA4 pin is "Open-Drain" type output pin. This means it cannot source current and it will be high impedance when assigned logic '1' to it. - You cannot set this pin as an output pin by only using 'TRISA=0x00'. The solution is attaching a pull up resistor (10K) to the RA4 pin in order to use this pin as an output pin.
  • 14. SWITCHES  We use switches to give an order to the MCU to do something by changing the voltage level applied on an I/O pin (input).
  • 15. SWITCHES  - Bouncing problem: The problem with using a mechanical switch is that switch contacts "bounce“ when you close the switch.
  • 16. SWITCHES - - - When the switch is closed, the two contacts actually separate and reconnect, typically 10 to 100 times in about 100ms. This bouncing would send multiple key press signals to the MCU which is not what you want. While 100 milliseconds is quite short for us as humans, it is actually quite long for a digital circuit and the period between spikes is often enough for the application to respond.
  • 17. SWITCHES Solution: 1-Using RC circuit: - We use it as a LPF, as the ripples happen very fast (high frequency). 2-By software: - By reading the value of the pin more than one time in small time intervals to make sure of the real value on the pin. - This done by testing the value, wait for some time (110 ms) and test again if the value is the same, so it’s the true value.
  • 18. LEDS  It’s the simplest way to indicate an output.  We have to use a current limiting resistor with it (typically 330Ω).
  • 19. APPLICATION 1 - Write a program outputs high on RC0, if RB0 is low using switches and leds.
  • 20. ASSIGNMENT - Write a code for a MCU that outputs these results on PORTC<5:7> for the inputs entered on PORTB<3:5>.  Write a function that handles the bouncing problem. PORTB (input) PORTC (output) 000 010 001 110 010 011 001 001