Advanced Programming Rabie A. Ramadan. Network Programming An Overview 2.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6.
-
Upload
eustacia-wells -
Category
Documents
-
view
225 -
download
4
Transcript of Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6.
Microprocessor
Dr. Rabie A. RamadanAl-Azhar University
Lecture 6
Interfacing I/O Devices
2
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
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
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
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
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
Execution of OUT Instruction and Timing
8
Execution of OUT Instruction and Timing
9
Basic Concepts in Interfacing Output Devices
10
Basic Concepts in Interfacing Output Devices
11
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
Interface Circuit
13
Interface Circuit
14
Using a Seven-Segment LED as a Display Device
15
Using a Seven-Segment LED as a Display Device
16
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
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
Execution of IN Instruction and Its Timing
The IN instruction has three machine cycles:
• Opcode Fetch,
• Memory Read port address
• I/O Read.
19
Execution of IN Instruction and Its Timing
20
Illustrative Example : Interfacing Input Switches
21
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
Some other examples from the book
23