UNIT 7 - INTRODUCTION TO I/O INTERFACING. TWO MAJOR TYPES OF I/O INTERFACING ISOLATED I/O - DEDICATED I/O INSTRUCTIONS ARE USED TO ACCESS I/O DEVICES.

Slides:



Advertisements
Similar presentations
I/O Organization popo.
Advertisements

INPUT-OUTPUT ORGANIZATION
8086 [2] Ahad. Internal! External? 8086 vs _bit Data Bus 20_bit Address 8_bit Data Bus 20_bit Address Only external bus of 8088 is.
3-1 Peripherals & I/O lines All the on-chip peripherals are configured and controlled through Special Function Registers (SFR) Many of the SFR’s are bit.
PROGRAMMABLE PERIPHERAL INTERFACE -8255
Programmable Keyboard/ Display Interface: 8279
Engineering 4862 Microprocessors Lecture 23 Cheng Li EN-4012
Chapter 2 HARDWARE SUMMARY
82C55 82C55 Programmable Peripheral Interface Interfacing Part III.
COMP3221: Microprocessors and Embedded Systems Lecture 17: Computer Buses and Parallel Input/Output (I) Lecturer: Hui.
8086.  The 8086 is Intel’s first 16-bit microprocessor  The 8086 can run at different clock speeds  Standard 8086 – 5 MHz  –10 MHz 
Direct Memory Access Introduction to 8237
I/O Unit.
Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that.
4-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Hardware Detail of Intel.
9/20/6Lecture 3 - Instruction Set - Al Hardware interface (part 2)
Unit-5 CO-MPI autonomous
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
INPUT-OUTPUT ORGANIZATION
Khaled A. Al-Utaibi  8086 Pinout & Pin Functions  Minimum & Maximum Mode Operations  Microcomputer System Design  Minimum Mode.
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
ECE 371- Unit 11 Timers and Counters (“Stop Watches and Alarm Clocks”)
The 8253 Programmable Interval Timer
3-1 Digital I/O A group of I/O pins is called a PORT  A port is where data enters/leaves the system. Digital I/O pins are usually grouped into 8,16 or.
Basic I/O Interface A Course in Microprocessor
Spring EE 437 Lillevik 437s06-l8 University of Portland School of Engineering Advanced Computer Architecture Lecture 8 Project 3: memory agent Programmed.
By, Prof. Tambe S. S. S.N.D. College of Engineering and Research Center Department of Electrical Engineering.
I NTRODUCTION P IN CONFIGARATION O PERATING MODE.
Computer Architecture Lecture 9 by Engineer A. Lecturer Aymen Hasan AlAwady 10/2/2014 University of Kufa - Information Technology Research and Development.
(More) Interfacing concepts. Introduction Overview of I/O operations Programmed I/O – Standard I/O – Memory Mapped I/O Device synchronization Readings:
8279 KEYBOARD AND DISPLAY INTERFACING
Direct Memory Access (DMA) Microprocessors I -1. Topics to be discussed  Basic DMA Concept Basic DMA Concept  DMA pins and timing DMA pins and timing.
ECE 371 – Unit 9 Interrupts (continued). Example Set up Two Interrupt Request Inputs: –Port H[0] Set Interrupt Flag on “0” to “1” transition (rising edge)
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Fall EE 333 Lillevik 333f06-l23 University of Portland School of Engineering Computer Organization Lecture 23 RAID Input/output design RS232 serial.
80386DX functional Block Diagram PIN Description Register set Flags Physical address space Data types.
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
PPI-8255.
8279 KEYBOARD AND DISPLAY INTERFACING
Programmable Interrupt Controller (PIC)
PROGRAMMABLE PERIPHERAL INTERFACE -8255
Basic LED Interface.
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.
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 9.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Chapter Microcontroller
8255:Programmable Peripheral Interface
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Multiplex of Data and Address Lines in 8088 Address lines A0-A7 and Data lines D0-D7 are multiplexed in These lines are labelled as AD0-AD7. –By.
Microcontroller based Traffic signal Umer Butt Amna Rashid Izza Rabbani Rozab Naveed Ramesha Akram.
Intel 8255A PPI EEE 365 [FALL 2014] LECTURE ATANU K SAHA BRAC UNIVERSITY.
HCS12 Technical Training Module 6 – Port Integration, Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All.
EEE /INSTR/CS F241 ES C263 Microprocessor Programming and Interfacing
PROGRAMMABLE PERIPHERAL INTERFACE -8255
EE3541 Introduction to Microprocessors
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
Dr. Michael Nasief Lecture 2
COMP2121: Microprocessors and Interfacing
Interfacing Memory Interfacing.
PROGRAMMABLE PERIPHERAL INTERFACE -8255
8255.
Parallel communication interface 8255
Programmable Peripheral Interface
82C55 Programmable Peripheral Interface
Port Integration Module
The Programmable Peripheral Interface (8255A)
Presentation transcript:

UNIT 7 - INTRODUCTION TO I/O INTERFACING

TWO MAJOR TYPES OF I/O INTERFACING ISOLATED I/O - DEDICATED I/O INSTRUCTIONS ARE USED TO ACCESS I/O DEVICES (TYPICALLY “IN” AND “OUT” INSTRUCTIONS) - SEPARATE CONTROL SIGNALS FOR MEMORY AND I/O, TYPICALLY: - MEMRIOR - MEMWIOW

MEMORY-MAPPED I/O SOME OF THE AVAILABLE MEMORY SPACE IS ASSIGNED TO I/O DEVICES. THE I/O DEVICES ARE THEN ACCESSED USING MEMORY-REFERENCE INSTRUCTIONS. - SAME CONTROL SIGNALS FOR MEMORY AND I/O, SUCH AS: - R/WOR- MEMR - ECLK- MEMW

A MORE EXTENSIVE INSTRUCTIONS SET CAN BE USED TO ACCESS I/O DEVICES. MORE ADDRESSING MODES ARE AVAILABLE. SOME OF MEMORY SPACE MUST BE GIVEN TAKEN AWAY FROM MEMORY TO GIVE TO I/O. MEMORY MAPPED I/O INSTRUCTIONS GENERALLY TAKE LONGER TO EXECUTE. ADVANTAGES OF MEMORY-MAPPED I/O DISADVANTAGES OF MEMORY I/O

“LINEAR SELECT” I/O ADDRESSING (CAN BE USED TO ADDRESS A NUMBER OF DEVICES EQUAL TO OR LESS THAN THE NUMBER OF ADDRESS LINES) A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A

decoderdecoder Latch Data Bus Addr. Bus Device IOR INTERFACE OF INPUT PORT TO DATA BUS WITH NO HANDSHAKING SIGNALS USED Typically Switches CLK OE Ox (373) G +5V OR

decoderdecoder Latch Data Bus Addr. Bus Device IOW INTERFACE OF OUTPUT PORT TO DATA BUS WITH NO HANDSHAKING SIGNALS USED Typically Lights CLK CP Ox (374) GND NOR OE

decoderdecoder Latch Data Bus Addr. Bus Printer INTERFACE OF OUTPUT PORT TO DATA BUS WITH HANDSHAKING SIGNALS GENERATED BY SOFTWARE CLK OE NOR Ox (374) CP GND IOW busy stb Latch IOR cp oe gnd oe G +5v Oz Oy OR NOR

USING I/O PORTS ON THE MC9S12DP256B MICROCONTROLLER

Port Interface Module – Block Diagram

Register x Descriptions Data Direction Register (DDRx) I/O Register (PTx) Input Register (PTIx) Reduced Drive Register (RDRx) Pull Enable Register (PERx) Polarity Select Register (PPSx) Port Interrupt Enable Register (PIEPx) Port Interrupt Flag Register (PIFx) Port Wired-Or Mode Register (WOMx) x: Register Name, e.g., T, S, M, P, H, J

Data Direction Register x x: T, S, M, P, H, J DDRx7DDRx6DDRx5DDRx4DDRx3DDRx2DDRx1DDRx0 DDRx[7:0] – Data Direction Port I 1 = Associated Pin is Configured as Output 0 = Associated Pin is Configured as Input

Port x I/O Register x: T, S, M, P, H, J PTx7PTx6PTx5PTx4PTx3PTx2PTx1PTx0 PTx[7:0] – Port I I/O Register Read Port If Direction is Input, Read State of Pin If Direction is Output, Read State of Buffer Write Port If Direction is Input, Data is Ignored If Direction is Output, Write Buffer

Port x Input Register x: T, S, M, P, H, J PTIx7PTIx6PTIx5PTIx4PTIx3PTIx2PTIx1PTIx0 PTIx[7:0] – Port x Input Register Reads State of Pins of Port x If Port x is output, can detect overloads by reading the actual state of the pin.

Reduced Drive Register Port x Direction is Output x: T, S, M, P, H, J RDRx7RDRx6RDRx5RDRx4RDRx3RDRx2RDRx1RDRx0 RDRx[7:0] – Reduced Drive Register Port x 1 = 1/3 Full Output Drive 0 = Full Output Drive

Port x Pull Device Enable Register Direction is Input x: T, S, M, P, H, J PERx7PERx6PERx5PERx4PERx3PERx2PERx1PERx0 PERx[7:0] – Pull Device Enable Register - Port x 1 = Enable Pull Device if Input 0 = Disable Pull Device if Input

Pull Device – Direction is Input Pull Up – Resistor to +5 Volts Pull Down – Resistor to Ground cpu gnd input Pull upPull down +5v

Port x Polarity Select Register Direction is Input x: T, S, M, P, H, J PPSx7PPSx6PPSx5PPSx4PPSx3PPSx2PPSx1PPSx0 PPSx[7:0] – Port x Polarity Select Register 1 = Enable Pull Down Rising Edge Sets Interrupt Flag – Ports P, H, J 0 = Enable Pull UP Falling Edge Sets Interrupt Flag – Ports P, H, J Dual Purpose for Ports P, H, J

Port x Interrupt Enable Register x: P, H, J (Input) PIEx7PIEx6PIEx5PIEx4PIEx3PIEx2PIEx1PIEx0 PIEx[7:0] – Port x Interrupt Enable Register 1 = Enable Interrupt = Unmask Interrupt 0 = Disable Interrupt = Mask Interrupt

Port x Interrupt Flag Register x: P, H, J (Input) PIFx7PIFx6PIFx5PIFx4PIFx3PIFx2PIFx1PIFx0 PIFx[7:0] – Port x Interrupt Flag Register 1 = Interrupt Pending (Write “1” to Clear Flag) 0 = No Interrupt Pending

Port x Wired-OR Mode Register x: S, M WOMx7WOMx6WOMx5WOMx4WOMx3WOMx2WOMx1WOMx0 WOMx[7:0] – Port x Wired-OR Mode Register Output Only 1 = Output is Open Drain 0 = Output is Push-Pull

Example

Sample Application Use Port H[3:0] to Read Inputs from Four Switches with Pull Ups Use Port H[7:4] to Send Out Four Bits Read from the Switches to a 374 Latch (which is connected to four LEDs) Use Port J[0] to Provide a Software- Initiated Clock Pulse to the 374 Latch

Example Components 374 Latch OE = 0 Enable Outputs “0”->”1” CP Latch Input Fig. 5.7

Port H Port Definitions (One Method) #define PTH _P(0x260) // port H data register #define PTIH _P(0x261) // port H input register #define DDRH _P(0x262) // port H direction register #define RDRH _P(0x263) // port H reduced drive register #define PERH _P(0x264) // port H pull device enable #define PPSH _P(0x265) // port H pull polarity select #define PIEH _P(0x266) // port H interrupt enable register #define PIFH _P(0x267) // port H interrupt flag register

Port H Port Definitions (Another Method) /* Port H Port Definitions */ #define PTH *(volatile unsigned char *) 0x260 #define PTIH *(volatile unsigned char *) 0x261 #define DDRH *(volatile unsigned char *) 0x262 #define RDRH *(volatile unsigned char *) 0x263 #define PERH *(volatile unsigned char *) 0x264 #define PPSH *(volatile unsigned char *) 0x265 #define PIEH *(volatile unsigned char *) 0x266 #define PIFH *(volatile unsigned char *) 0x267

Port H Initialization /* Initialize Port H */ DDRH = 0xF0; // 7:4 Out, 3:0 In RDRH = 0x00; // Full Drive on Output PERH = 0x00; // Disable Pull Devices on Input //PERH = 0x0F; // Enable Pull DEvices //PPSH = 0x00; // Pull Ups on Inputs (Not Required) PIEH = 0x00; // Disable Interrupts PIFH = 0xFF; // Clear Interrupt Flag Register /* The switches have pull ups and thus microcontroller is not required to supply */

Port J Port Definitions #define PTJ _P(0x268) // port J data register #define PTIJ _P(0x269) // port J input register #define DDRJ _P(0x26A) // port J direction register #define RDRJ _P(0x26B) // port J reduced drive register #define PERJ _P(0x26C) // port J pull device enable #define PPSJ _P(0x26D) // port J pull polarity select #define PIEJ _P(0x26E) // port J interrupt enable register #define PIFJ _P(0x26F) // port J interrupt flag register

Port J Initialization /* Initialize Port J */ /* Set Data Direction Register – Port J Set Bit 0 of Port J to Output Do not change direction of Bits 1 through 7 Read state of Port J Data Direction Register Bitwise Or State with 0x01 Write Data Direction Register – Port J */ DDRJ = DDRJ | 0x01; // Bit 0 is Out

Port J Initialization /* Read State of Reduced Drive Register – Port J Bitwise AND State with 0xFE Write Reduced Drive Register - Port J*/ RDRJ = RDRJ & 0xFE; // Bit 0 is Full Output /* Read State of Interrupt Enable Register – Port J Bitwise AND Value Read Write Interrupt Enable Register – Port J */ PIEJ = PIEJ & 0xFE; // Disable Bit 0 Interrupt /* Init Bit 0 of Port J to 0 */ PTJ = PTJ & 0xFE;

Read Port H Shift Input Bits Left 4 Places Write Port H Latch Strobe PTJ0 = 1 PTJ0 = 0 Application Flow Diagram

Application Code /* Read Inputs, Output, Strobe Output into Latches */ PTH = PTH<<4; // Read input, shift 4 left and Output PTJ = PTJ | 0x01; // Set Strobe = 1 PTJ = PTJ & 0xFE; // Set Strobe = 0

Parallel Printer Port Example

Parallel Printer Interface Printer /Strobe Busy Data[7:0] Busy Write Data Strobe Yes No

Printer J[1] J[0] 68HC12 H[7:0] Latch Busy Data /Strobe Parallel Printer Interface

Busy Data /Strobe Printer Waveforms PC Parallel Printer Port Definition

/* initialize Port H to Output, Full Drive, Printer Data */ DDRH = 0xFF; // Output Direction RDRH = 0x00; // Full Drive /* Bit 0 Port J - /Strobe Output Bit 1 Port J – Busy Input */ DDRJ = (DDRJ & 0xFC)| 0x01; /* Full Drive for Bit 0 Port J */ RDRJ = RDRJ & 0xFE; /* Enable Pull for Input */ PERJ = PERJ | 0x2; /* Use Pull Up on Input */ PPSJ = PPSJ | 0xFD; /* Strobe Initially High */ PTJ = PTJ | 0x01;

Print a Character on Printer void printc(unsigned char c) { /* Wait while Printer is Busy */ while((PTJ&0x02)!=0); /* Printer not Busy, Output Data */ PTH = c; /* Generate Strobe * PTJ = PTJ & 0xFE; // Bit 0 Low PTJ = PTJ | 0x01; // Bit 0 High }

Example – Parallel Interface of 2 Computers (Send Byte from A to B) Port H Out Port J[0] Out Port J[1] In Port H Input Port J[0] In Port J[1] Out Computer AComputer B

Port H J[0] J[1] Timing Diagrams Valid Data Strobe Data Acknowledge Data (Sent by Computer A) (Sent by Computer B)

Computer Software (Pseudo Code) Computer A Initialize: Port H Direction Out Port J[0] Out Port J[1] Input Port J[0] = 0; Write a byte: Wait until Compute B is Ready Present Data to Comp. B Begin Strobe Pulse Wait for Acknowledge End Strobe Pulse Computer B Initialize: Port H Direction In Port J[0] In Port J[1] Output Port J[1] = 0; Read a byte: Wait for Strobe from Computer A Read Port H; Begin Acknowledge Pulse Wait for Strobe to End End Acknowledge Pulse

Computer A // Initialize Port H and Port J DDRH = 0xFF //Port H is Output Port DDRJ = (DDRJ &0xFC) | 0x1; //xxxxx01, J[1] = input, J[0] is output PTJ = PTJ & 0xFE; //xxxxxxx0, send 0 from J[0] //Write a byte while ((PTJ&0x02)!=0); //Wait until Compute B is Ready PTH = data; //Send data out on Port H, to Computer B PTJ = PTJ | 0x01; //Begin strobe pulse to Computer B while ((PTJ&0x2)==0); //Wait until Comp. B has acknowledged data PTJ = PTJ &0xFE; //End strobe pulse to Computer B

Computer B // Initialize Computer B DDRH = 0x00; // //Port H is Input Port DDRJ = (DDRJ & 0xFC) | 0x02; //xxxxxx10, J[1] = output, J[0] is input PTJ = PTJ & 0xFD; //xxxxxx0x, initialize J[1] to 0 // Read a byte while((PTJ&0x01)==0); //Wait until Computer A has sent data Data = PTH; //Read data from Computer A PTJ = PTJ | 0x02; //Begin Acknowledge pulse, sent to Computer A while((PTJ&0x01)!=0); //Wait for Strobe Pulse from Computer A to end PTJ = PTJ & 0xFD; // End Acknowledge pulse, sent to Computer A

ANOTHER EXAMPLE Digital Lock 5 Switches CPUPort H[7] Port H[4:0] Unlock 5 Switches -> Port H[4:0] Port H switches are marked as: A, B, C, D, E

5 Momentary Contact Switches 5 Switches -> Port H Port H switches are marked as: A, B, C, D, E Port H [0] =“A”, Port H[1]=“B”, Port H[2]=“C” Port H[3]=“D’, Port H[4]=“E” Switches are normally open – “1” in Input Press Switch - “0” in Input Digital Code is Sequence to Unlock Door B, D, E, C, A Detect Sequence to Unlock Port H[7] -- Unlock

Initialize Interface /* Push Button Codes */ #define A 0x1E // #define B 0x1D // #define C 0x1B // #define D 0x17 // #define E 0x0F // /* Port H Symbol Definitions */ #define PTH _P(0x260) // port H data register #define PTIH _P(0x261) // port H input register #define DDRH _P(0x262) // port H direction register #define RDRH _P(0x263) // port H reduced drive register #define PERH _P(0x264) // port H pull device enable #define PPSH _P(0x265) // port H pull polarity select #define PIEH _P(0x266) // port H interrupt enable register #define PIFH _P(0x267) // port H interrupt flag register

int main(void) {unsigned char state=0,insw,flag=0; /* initialize the Port H Interface */ DDRH = 0x80; // Bit 7 is Output, Bits 0-6 are input RDRH = 0x00; // Full Drive PERH = 0x7f; // Enable Pull Device (Not Required) PPSH = 0x00; // Enable Pull Up PTH = 0x00; // Bit 7=0 // forever loop while(flag==0) {while((PTH&0x1F)==0x1F); // wait while not pressed // switch was pressed, go process insw = PTH & 0x1F; // read switches

switch (state) { case 0: if(insw==B) state=1; break; case 1: if(insw==D) state=2 else state=0; break; case 2: if(insw==E) state=3 else state=0; break; case 3: if(insw==C) state=4 else state=0; break; case 4: if(insw==A) {PTH=0x80; // unlock door PTH = 0x00; state=0;} } while((PTH&0x1F)!=0x1F); //Wait until not pressed }