I/O Devices Switches, LED, LCD

Slides:



Advertisements
Similar presentations
I/O Organization popo.
Advertisements

INPUT-OUTPUT ORGANIZATION
1 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs Parallel IO Ports E.g. Port T, Port AD Used to interface with many devices Switches LEDs.
Autumn 2012C.-S. Shieh, EC, KUAS, Taiwan1 The 8051 Family Microcontroller Chin-Shiuh Shieh Department of Electronic Engineering.
Week10 Boolean Instructions on the Boolean Instructions  Boolean (or Bit) addressable capability is unique to the 8051  Enables efficient handling.
PROGRAMMABLE PERIPHERAL INTERFACE -8255
8051 I/O Interfacing Need for more ports PPI 8255
kashanu.ac.ir Microprocessors 6-1 I/O Devices Switches, LED, LCD Lec note 6.
TK2633 Introduction to Parallel Data Interfacing DR MASRI AYOB.
Input/Output (I/O) Ports and Interfacing
Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Engineering 4862 Microprocessors Lecture 23 Cheng Li EN-4012
82C55 82C55 Programmable Peripheral Interface Interfacing Part III.
Microprocessor and Microcontroller
I/O Unit.
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
Interfacing of 8051 UNIT 4.
1 TK2633TK Microprocessor Architecture DR MASRI AYOB.
Input-Output Problems L1 Prof. Sin-Min Lee Department of Mathematics and Computer Science.
Practical Session No. 10 Input &Output (I/O). I/O Devices Input/output (I/O) devices provide the means to interact with the “outside world”. An I/O device.
1 COSC 3P92 Cosc 3P92 Week 11 Lecture slides Violence is the last refuge of the incompetent. Isaac Asimov, Salvor Hardin in "Foundation"
kashanu.ac.ir Microprocessors 10-1 IO Devices Stepper Motors DAC, ADC, PPI Lec note 10.
I/O devices Peripheral devices (also called I/O devices) are pieces of equipment that exchange data with a CPU Examples: switches, LED, CRT, printers,
Embedded Systems Design 1 Lecture Set B Interfacing the MCS-51 to: –7 and 16 segment displays –a Multiplexed 7-Segment Display –a Keypad –an LCD.
Lecture – 7 Basic input and output
INPUT-OUTPUT ORGANIZATION
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
1 4-Integrating Peripherals in Embedded Systems (cont.)
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
Input/Output Ports and Interfacing
MCS-51 Hardware Interfacing
ECE 353 Introduction to Microprocessor Systems Michael Schulte Week 7.
MICROPROCESSOR INPUT/OUTPUT
BASIC INPUT AND OUTPUT INTERFACING.  8085A communicate with outside world using the I/O devices.  Since memory and I/O devices share the system bus,
Basic I/O Interface A Course in Microprocessor
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
I/O devices Peripheral devices (also called I/O devices) are pieces of equipment that exchange data with a CPU Examples: switches, LED, CRT, printers,
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
8086/8088 Hardware Specifications Power supply:  +5V with tolerance of ±10%;  360mA. Input characteristics:  Logic 0 – 0.8V maximum, ±10μA maximum;
(More) Interfacing concepts. Introduction Overview of I/O operations Programmed I/O – Standard I/O – Memory Mapped I/O Device synchronization Readings:
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Programmable Peripheral Interface Parallel port Interface 8255
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
Module 11 Adapted By and Prepared James Tan © 2001.
PPI-8255.
Programmable Interrupt Controller (PIC)
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
EE365 - Microprocessors period 26 10/23/00 D. R. Schertz # Parallel Ports.
Department of Electronic & Electrical Engineering LCD character display (parallel interface). How to interface a LCD character display to a PIC.
KEYBOARD INTERFACING Keyboards are organized in a matrix of rows and columns The CPU accesses both rows and columns through ports. ƒTherefore, with two.
Alpha/Numeric Keypad Functions using AVR Preliminary Design Review Luke R. Morgan ECE /17/2008.
بسم الله الرحمن الرحيم MEMORY AND I/O.
 The Programmable Interrupt Controller (PlC) functions as an overall manager in an Interrupt-Driven system. It accepts requests from the peripheral equipment,
LED AND KEYBOARD INTERFACING PREPARED BY :- PREPARED BY :- RAVAL AKASH ( ) RAVAL AKASH ( ) PATEL HARDIK ( ) PATEL HARDIK.
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
LCD and Keyboard Interfacing
DIGITAL CALCULATOR USING 8051
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
EET 2261 Unit 11 Controlling LCD and Keypad
Interfacing Memory Interfacing.
LCD and Keyboard Interfacing
8255.
EET 2261 Unit 11 Controlling LCD and Keypad
LCD and Keyboard Interfacing
Parallel communication interface 8255
82C55 Programmable Peripheral Interface
LCD and Keyboard Interfacing
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
The Programmable Peripheral Interface (8255A)
Presentation transcript:

I/O Devices Switches, LED, LCD Week 9

I/O devices (Peripherals) Examples: switches, LED, LCD, printers, keyboard, keypad Interface chips are needed to resolve the speed problem synchronizes data transfer between CPU and I/O device Connection of Interface and CPU Data pins are connected to CPU data bus I/O port pins are connected to I/O device CPU may be connected to multiple interface IO ports are simplest interface

I/O Interfacing Dedicated instructions for IO operations (Isolated I/O) same instruction for memory and IO (memory-mapped I/O) MCS-51 (8051) is memory mapped

Synchronization of CPU and interface chip To make sure that there are valid data in the interface two ways Polling method: Read status bit - Simple method Interrupt driven method: interface interrupts the CPU when it has new data - CPU executes the ISR

Synchronization of CPU and interface chip Output synchronization: two ways of doing this Polling method interface chip uses a status bit to indicate that the data register is empty CPU keeps checking status bit until it is set, and then writes data into interface chip Interrupt driven method: interface chip interrupts the CPU when it data register is empty. CPU executes the ISR

Synchronization of CPU and interface chip Methods used to synchronize data transfer between interface chip and I/O devices: Brute force method: interface chip returns voltage levels in its input ports to CPU and makes data written by CPU directly available on its output ports All 8051 port can perform brute force I/O Strobe method: During input, the I/O device activates a strobe signal when data are stable. Interface chip latches the data For output, interface chip places output data on output port. when data is stable, it activates a strobe signal. I/O device latches the data Handshake method: two handshake signals are needed One is asserted by interface chip and the other by I/O device

8051 - Switch On I/O Ports Case-1: Case-2: Case-3: Gives a logic 0 on switch close Current is 0.5ma on switch close Case-2: Gives a logic 1 on switch close High current on switch close Case-3: Can damage port if 0 is output

Simple input devices DIP switches usually have 8 switches Use the case-1 from previous page Sequence of instructions to read is: MOV P1,#FFH MOV A,P1,

Bouncing contacts Contact: Push-button switches Toggle switches Electromechanical relays Make and break Contact normally open switch The effect is called "contact bounce" or, in a switch, "switch bounce”. If used as edge-triggered input (as INT0), several interrupt is accorded

Hardware Solution An RC time constant to suppress the bounce The time constant has to be larger than the switch bounce Vcc OUT

Hardware Solution

Software Solution Read the new state of switch N time Wait-and-see technique When the input drops an “appropriate” delay is executed (10 ms) then the value of the line is checked again to make sure the line has stopped bouncing

Interfacing a Keypad Place a 0 on R0 port Read C port 16 keys arranged as a 4X4 matrix Place a 0 on R0 port Read C port If there is a 0 bit then the button at the column/row intersection has been pressed. Otherwise, try next row Repeat constantly 1 2 3 5 6 7 D E F 9 A B C 8 4

Interfacing a Keypad 8051 scan: mov P1,#EFH jnb P1.0,db_0 scan1: jnb P1.1,db_1 scan2: jnb P1.2,db_2 scan3: jnb P1.3,db_3 scan4: mov P1,#DFH jnb P1.0,db_4 ….. 8051 F E D C B A 9 8 7 6 5 4 3 2 1

Interfacing a Keypad get_code: mov DPTR, #key_tab movc A, @A+DPTR db_0: lcall wt_10ms jb P1.0, scan1 mov A, #0 ljmp get_code db_1: lcall wt_10ms jb P1.1, scan2 mov A, #1 ….. … get_code: mov DPTR, #key_tab movc A, @A+DPTR ljmp scan key_tab: db ‘0123456789ABCDEF’ END

Simple output devices Case-1 Case-2 Case-3 LED is ON if output=zero Most LEDs drop 1.7 volts and need about 10ma Current is (5-1.7)/470 Case-2 Too much current Failure of Port or LED Case-3 Not enough drive (1ma) LED is too dim

The 7-Segment Display 7 LEDs arranged to form the number 8. By turning on and off (LEDs), different combinations can be produced. useful for displaying the digits 0 through 9, and some characters. a b c f e g d

The 7-segment Display (Cont.) 7-segment displays come in 2 configurations: Common Anode Common Cathode Connect cathode to the output Connect cathode to the output Therefore, the common anode variety would be better for our interfacing needs.

Interfacing a 7-segment display A resistor will be needed to control the current This leaves two possibilities: Case 2 would be more appropriate Case 1 will produce different brightness depending on the number of LEDs turned on. Case1 Case 2

ET2640 Microprocessors and Microcontrollers

ET2640 Microprocessors and Microcontrollers

ET2640 Microprocessors and Microcontrollers

Continued on next slide ET2640 Microprocessors and Microcontrollers

Continued from previous ET2640 Microprocessors and Microcontrollers

Use of current buffer Interfacing to a DIP switch and 7-segment display Output a ‘1’ to ON a segment We can use 74244 to common cathode 7_seg

LCD Connections ET2640 Microprocessors and Microcontrollers

BCD to 7_Seg lookup table p g f e d c b a 7_seg hex 0000 0 0 1 1 1 1 1 1 3f 0001 0 0 1 1 0 0 0 0 30 0010 0 1 0 1 1 0 1 1 5b 0011 0 1 0 0 1 1 1 1 4f 0100 0 1 1 0 0 1 1 0 66 0101 0 1 1 0 1 1 0 1 6d 0110 0 1 1 1 1 1 0 1 7d 0111 0 0 0 0 0 1 1 1 07 1000 0 1 1 1 1 1 1 1 7f 1001 0 1 1 0 1 1 1 1 6f mov a,p3 anl a,0fh get_code: mov DPTR, #7s_tab movc A, @A+DPRT mov p1,a 7s_tab: db 3fh,30h,5bh,4fh,66h db 6dh,7dh,07h,7fh,6fh END a a a a a a a a f b f b b f b f f b f b f b g g g g g g g e c e e c c c e c c e c c d d d d d d d

LCD Interfacing Liquid Crystal Displays (LCDs) cheap and easy way to display text Various configurations (1 line by 20 X char up to 8 lines X 80) Integrated controller The display has two register command register data register By RS you can select register Data lines (DB7-DB0) used to transfer data and commands

Alphanumeric LCD Interfacing R/W RS DB7–DB0 LCD controller communications bus Microcontroller 8 LCD Module Pinout 8 data pins D7:D0 RS: Data or Command Register Select R/W: Read or Write E: Enable (Latch data) RS – Register Select RS = 0  Command Register RS = 1  Data Register R/W = 0  Write , R/W = 1  Read E – Enable Used to latch the data present on the data pins. D0 – D7 Bi-directional data/command pins. Alphanumeric characters are sent in ASCII format.

LCD Commands The LCD’s internal controller can accept several commands and modify the display accordingly. Such as: Clear screen Return home Decrement/Increment cursor After writing to the LCD, it takes some time for it to complete its internal operations. During this time, it will not accept any new commands or data. We need to insert time delay between any two commands or data sent to LCD

Command Codes

LCD Addressing

LCD Timing

Interfacing LCD with 8051 8051 LM015 RW E RS P1.7-P1.0 D7-D0 P3.4 P3.5

Interfacing LCD with 8051 mov A, command call cmd delay mov A, another_cmd mov A, #’A’ call data mov A, #’B’ …. Command and Data Write Routines data:mov P1, A ;A is ascii data setb P3.3 ;RS=1 data clr P3.4 ;RW=0 for write setb P3.5 ;H->L pulse on E clr P3.5 ret cmd:mov P1,A ;A has the cmd word clr P3.3 ;RS=0 for cmd setb P3.5 ;H->L pulse on E Interfacing LCD with 8051

Example

8255 Usage: Simple Example 8255 memory mapped to 8051 at address C000H base A = C000H, B = C001H, C = C002H, CR = C003H Control word for all ports as outputs in mode0 CR : 1000 0000b = 80H test: mov A, #80H ; control word mov DPTR, #C003H ; address of CR movx @DPTR, A ; write control word mov A, #55h ; will try to write 55 and AA ; alternatively repeat:mov DPTR,#C000H ; address of PA movx @DPTR, A ; write 55H to PA inc DPTR ; now DPTR points to PB movx @DPTR, A ; write 55H to PB inc DPTR ; now DPTR points to PC movx @DPTR, A ; write 55H to PC cpl A ; toggle A (55AA, AA55) acall MY_DELAY ; small delay subroutine sjmp repeat ; for (1)

Next Week—Week10 Unit 10 Quiz Interfacing with A/D and D/A Converters