Dr. Rabie A. Ramadan Al-Azhar University Lecture 6 Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
Interfacing I/O Devices
I/O modes Serial Mode Parallel Mode Data entered or exited in parallel 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
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.
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.
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.
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.
Execution of OUT Instruction and Timing
Execution of OUT Instruction and Timing
Basic Concepts in Interfacing Output Devices
Basic Concepts in Interfacing Output Devices
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
Interface Circuit
Interface Circuit
Using a Seven-Segment LED as a Display Device
Using a Seven-Segment LED as a Display Device
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.
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.
Execution of IN Instruction and Its Timing The IN instruction has three machine cycles: Opcode Fetch, Memory Read port address I/O Read.
Execution of IN Instruction and Its Timing
Illustrative Example : Interfacing Input Switches
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.
Some other examples from the book