1 / 22

COMP3221: Microprocessors and Embedded Systems

COMP3221: Microprocessors and Embedded Systems. Lecture 18: Computer Buses and Parallel Input/Output (II) http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2004. Overview. Bus Arbitration Switches. Bus Masters and Slaves.

Download Presentation

COMP3221: Microprocessors and Embedded Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMP3221: Microprocessors and Embedded Systems Lecture 18: Computer Buses and Parallel Input/Output (II) http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2004

  2. Overview • Bus Arbitration • Switches COMP3221/9221: Microprocessors and Embedded Systems

  3. Bus Masters and Slaves • A bus master is either a CPU or a hardware component (DMA Controller for instance) that controls the buses. • A bus slave is a device that takes its orders from the bus master. • What if two or more bus masters want to control the buses simultaneously? • Bus arbitration is required. COMP3221/9221: Microprocessors and Embedded Systems

  4. Bus Arbitration • Daisy chain bus arbitration. • Hardware priority bus arbitration.

  5. Daisy Chain Bus Arbitration HOLD Master 1 Master 2 Master n Intel 8086 CPU • • • HOLDA

  6. Daisy Chain Bus Arbitration (Cont.) • Whenever a device wants to control the bus, it asserts HOLD and opens the switch in the HOLDA (HOLD_ACKNOLEDGE) line. • When HOLDA is asserted by the CPU, it passes through each of the inactive one. • If a bus master farther right on the chain asserts HOLD before another master is finished, HOLDA is not passed along until the higher priority device (closer to CPU) is finished with its tasks and closes its switch.

  7. Hardware Priority Bus Arbitration HOLD Priority Encoder Priority Resolution Hardware Intel 8086 CPU HOLDA HOLD1 HOLD2 HOLDn HOLDA1 HOLDA2 HOLDAn Master 1 Master 2 Master n • • •

  8. Hardware Priority Bus Arbitration • Each device is pre-assigned a priority. • Simultaneous HOLD signals are encoded so that only the highest priority device receives HOLDA.

  9. Input Switches • Most basic of all binary input devices. • The switch output is high or low depends on the the switch position. • Pull-up resistors are necessary in each switch to provide a high logic level when the switch is open. • Problem with switches: • Switch bounce. • When a switch makes contact, its mechanical springiness will cause the contact to bounce, or make and break, for a few millisecond (typically 5 to 10 ms).

  10. Input Switches (Cont.) Vcc R Typically 1K Ohm Logic high with switch open ½ 74LS244 Octal Buffer Logic low with switch closed Data Bus (a) Single-pole, single-throw (SPST) logic switch Data Bus (b) Multiple pole switch.

  11. Software Debouncing Two software debouncing approaches: • Wait and see: • If the software detects a low logic level, indicating that switch has closed, it simply waits for longer than 10 ms, say 20 to 100ms, and then test for the switch still being low. • Counter-based approach: • Initialize a counter to 10. • Poll the switch every millisecond until the counter is either 0 or 20. If the switch output is low, decrement the counter; otherwise, increment the counter. • If the counter is 0, we know that switch output has been low for at least 10 ms. If, on the other hand, the counter reaches 20, we know that the switch has been closed for at least 10 ms.

  12. NAND Latch Debouncer R Typically 1K Ohm Logic high with switch up Logic low with switch down

  13. NOR Latch Debouncer Vcc Logic high with switch up Logic low with switch down

  14. Integrating Debouncer with Schmitt Trigger R Logic high with switch up Logic low with switch down 74LS14 Schmitt Trigger

  15. One-Dimensional Array of Switches Vcc A I0 74LS151 8 to 1 Multiplexer I1 Scanned Switch Data To Input Port I2 I3 Z I4 I5 I6 I7 E S2 S1 S0 Selected Input From Output Port

  16. One-Dimensional Array of Switches • Switch bounce problem must be solved. • The array of switches must be scanned to find out which switches are closed or open. • Software is required to scan the array. As the software outputs a 3-bits sequence from 000 to 111, the multiplexer selects each of the switch inputs. The software scanner then read one bit at an input port. • The output of switch array could be interfaced directly to an eight-bit port at point A. • To save I/O lines, a 74LS151 8_Inpu Multiplexer can be used.

  17. Keyboard Matrix of Switches Vcc 11 74LS151 8-Input Multiplexer A 00 01 02 06 07 I0 10 11 12 17 I1 Scanned Switch Data To Input Port I2 I3 Z I4 I5 I6 I7 B 70 71 77 E S2 S1 S0 Vcc O0 O1 O2 O3 O4 O5 O6 O7 E3 E2 E1 A2 A1 A0 Select Input From Output Port 74LS138 3-of-8 Decoder Scan Input From Output Port

  18. Keyboard Matrix of Switches (Cont.) • A keyboard is an array of switches arranged in a two-dimensional matrix. • A switch is connected at each intersection of vertical and horizontal lines to the vertical. • Closing the switch connects the horizontal line to the vertical line. • 8*8 keyboard can be interfaced directly into 8-bit output and input ports at point A and B. • Some input and output lines can be saved by using a 74LS138 3-of-8 decoder and a 74LS151 8-Input Multiplexer.

  19. Keyboard Matrix of Switches (Cont.) • Software can scan the key board by outputting a three-bit code to 74LS138 and then scanning the 74LS151 multiplexer to find the closed switch. • The combination of the two 3-bit scan codes identifies which switch is closed. For example, the code 000000 scan switch 00 in the upper left-hand corner. • The diode prevents a problem called ghosting.

  20. Ghosting Vcc R3 R2 R1 Col 0 Col 1 Col 2 00 01 02 Row 0 (Pulled low, error) 10 11 12 Row 1 (Pulled low, OK) 20 21 22 Row 2 (High, OK) Low (Scanned column)

  21. Ghosting (Cont.) • Ghosting occurs when several keys are pushed at once. • Consider the case shown in the figure where three switches 01, 10 and 11 are all closed. Column 0 is selected with a logic low and assume that the circuit does not contain the diodes. As the rows are scanned, a low is sensed on Row 1, which is acceptable because switch 10 is closed. In addition, Row 0 is seen to be low, indicating switch 00 is closed, which is NOT true. The diodes in the switches eliminate this problem by preventing current flow from R1 through switches 01 and 11. Thus Row 0 will not be low when it is scanned.

  22. Reading • Chapter 7: Computer Buses and Parallel Input and Output. Microcontrollers and Microcomputers by Fredrick M. Cady. COMP3221/9221: Microprocessors and Embedded Systems

More Related