23
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Embed Size (px)

Citation preview

Page 1: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Microprocessor

Dr. Rabie A. RamadanAl-Azhar University

Lecture 6

Page 2: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Interfacing I/O Devices

2

Page 3: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

I/O modes Serial Mode

Data entered or exited in serial

Parallel Mode • Data entered or exited in parallel

• Interfaced through:• Peripheral mapped I/O

• Each device has a 8-bit address and enabled by I/O related control signals

• Memory mapped I/O

• Each device has a 16-bit address and enabled by memory related control signals

3

Page 4: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Interfacing I/O Devices

The Z80 uses the instructions: •

• IN to read (input) data from an input device and

• OUT to write (send) data to an output device.

4

Page 5: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

OUT Instruction

It can send data from the accumulator, internal-purpose registers, or memory registers to an output device.

The OUT instructions include:

• 8 bit address of a device as an operand.

• The address range from 00H to FFH is called the I/O or peripheral map,

• An address can be referred to as a device address, port address, or port number.

5

Page 6: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Example

When the microprocessor reads and executes the machine codes written at memory register 2050H and 2051H, it will transfer (copy) the byte from the accumulator to the LED port with address 07H and display the byte.

6

Page 7: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Execution of OUT Instruction and Timing

The OUT has three machine cycles;• Opcode Fetch,

• Memory Read and

• I/O Write.

The Z80 reads the opcode and the port address

from memory in the first two machine cycles and writes into the port in the third cycle.

7

Page 8: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Execution of OUT Instruction and Timing

8

Page 9: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Execution of OUT Instruction and Timing

9

Page 10: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Basic Concepts in Interfacing Output Devices

10

Page 11: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Basic Concepts in Interfacing Output Devices

11

Page 12: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Illustrative Example 1: Interfacing LEDs

Hardware 7475 Latch

• 4 D-Latches

• 2 enable lines

47LS373 Octal Latch

• Latch followed by

tri- state buffer

• Reduces using

the data bus

• 8 latches instead of 4

12

Page 13: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Interface Circuit

13

Page 14: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Interface Circuit

14

Page 15: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Using a Seven-Segment LED as a Display Device

15

Page 16: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Using a Seven-Segment LED as a Display Device

16

Page 17: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Interfacing INPUT Devices

IN instruction

• Read (copy) data from such input devices as switches, keyboard, and A/D data converters.

• Can read an input device and place the data into the accumulator, Z80 registers, or memory registers.

17

Page 18: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Example

First read the machine codes stored at locations 2065H and 2066H,

Read the switch positions at port 84H by enabling the interfacing device of the port.

The data byte indicating switch positions from the input port will be placed in the accumulator.

18

Page 19: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Execution of IN Instruction and Its Timing

The IN instruction has three machine cycles:

• Opcode Fetch,

• Memory Read port address

• I/O Read.

19

Page 20: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Execution of IN Instruction and Its Timing

20

Page 21: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Illustrative Example : Interfacing Input Switches

21

Page 22: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Multiple Port Addresses

the address lines A4 and A3 are not used by the decoding circuit; the logic levels on these lines can be either 0 or 1.

22

Page 23: Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6

Some other examples from the book

23