Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
Objectives
Parallel and Serial Mode Identify device/port address of peripheral-mapped I/O and
memory mapped I/O OUT & IN instructions. Memory related instructions Differentiate peripheral-mapped and memory-mapped I/O To interface 8085 with other devices
Parallel Vs Serial Parallel I/O - All 8-bits of data are transferred between 8085
and external device using the entire data bus
Serial I/O - Bits are transferred one at a time, along one data
line
2
Introduction
I/O Port Identification and Addressing
Memory Mapped I/O
Access and identify as memory registers using memory space Memory related control signal 16-bit address i.e. from 0000H to FFFFH 8085 treats I/O ports as if it was communicating with a
memory location
Peripheral Mapped I/O
Separate address scheme (8-bit i.e from 00H to FFH) Enabled and identified by I/O related control signals
Data transfer process is identical for both method Need to understand the foundation I/O operations in 8085
3
bus -Send the control signals -Enable the interfacing device -Transfer data
Things to understand:
How 8085 selects an I/O device? What hardware chips are necessary?
What software instructions are used? How data are transferred?
basic concept in interfacing. The difference is the Instructions used for each.
4
D3)
IN - data input into the accumulator from device
eg. Keyboard OUT - data output from accumulator to device e.g printer, display
2050
2051
D3
01
OUT 01H
11010011
00000001
P ERIPHERAL I/ O I NSTRUCTIONS
OUT I NSTRUCTION
accumulator to an output device with the address 10H. (address is also called port number of device)
Address of output device is 8-bit long, so 8085 can communicate
our application.
M2 (Memory Read) T1 T2 T3 T1
M3 (I/O Write) T2 T3
20H
20H
50H
Opcode D3H
51H
01H
Place high order memory address 20H on A15-A8 Place low order memory address 50H on AD7-AD0 ALE goes high and IO/M' goes low. ALE indicates the availability of AD7-AD0 and used to demultiplex the bus IO/M' low indicates a memory related operation At T2, (RD)' (active low) signal is sent and combined with IO/M' signal to activate the (MEMR)' signal (active low) Fetch the instruction code D3 using data bus, decodes it, finds out that it suppose to be 2-byte, so must read the second byte.
8
At the third machine cycle M3 01H is placed on the low-order (AD7-AD0) and high-order (A15-A8)
address bus IO/M' goes high to indicate I/O operation. At T2, the content of accumulator is placed on data bus (AD7-AD0), followed by control signal (WR). ANDing the IO/M' and (WR)' signal, the (IOW)' is generated to enable the output device
The data remains on the data bus (AD7-AD0) for two T-states (T2 & T3),
before the processor executes the next instruction. Therefore we must latch the data bus within the two T-states before it is lost.
2065 2066
DB 84
IN 84H
11011011 10000100
(DBH) (84H)
and read the switch positions (input data) at port 84H by enabling the interfacing device of the port.
Input data byte containing the switch positions from the input
M2 (Memory Read) T1 T2 T3 T1
M3 (I/O Write) T2 T3
20H
20H
65H
Opcode DBH
66H
84H
11
order AD7-AD0 and low order A15-A8 address bus Sends (RD)' signal, which will prompt I/O Read signal, (IOR)' The (IOR)' enables input port, data obtained from port onto the bus and placed into the accumulator. M3 for IN and OUT are essentially the same, the differences are
IN
use (RD)', OUT use (WR)' Data flow from input port to accumulator for IN, from accumulator to output port for OUT
12
accumulator will be on the data bus for a period of two Tperiods only.
To catch the data, we need a data latch so that we can
Questions: 1. When should we enable the latch? 2. What is the address of the latch?
13
The answer to both is at M3: -The latch should be enabled when IO/M is active high and WR is active low - The address of the port is also available at M3 Need to create: Pulse to indicate the presence of address on bus Generate timing pulse to indicate data byte is on the bus Use both pulse to enable the latch to catch the data
14
To Peripherals
AND
Control Signal or Device Select Pulse
Figure shows the basic blocks of a decoding circuit. The process are summarized as follows: Decode address bus to generate a unique pulse corresponding to the device address on the bus; this is called the device address pulse or I/O address pulse. Combine (AND) the device address pulse with the control signal to generate a device select (I/O select) pulse that is generated only when both signals are asserted. Use the I/O select pulse to activate the interfacing device (I/O port).
15
functions as decoder Address 01H (00000001), A0 directly connected, A7 inverted to produce 01H G1 generate low pulse (active low)and combines with G2, which is low too, to select (IOSEL) or enable the data latch At this time the content of the accumulator is on the data bus IOSEL will clock the latch to catch the data, and send the data to the output device.
17
Absolute Decoding All eight address lines are decoded to generate unique pulse Figure shows unique pulse will be generated if and only if address 01H (ooooooo1) is on the address bus Good design practice Costly (uses many extra devices/gates) Our previous decoding circuit employs this technique
18
20
22
0
0 0 1 1 1 1
0
1 1 0 0 1 1
1
0 1 0 1 0 1
1
1 1 1 1 1 0
1
1 1 1 1 0 1
1
1 1 1 0 1 1
1
1 1 0 1 1 1
1
1 0 1 1 1 1
1
0 1 1 1 1 1
0
1 1 1 1 1 1
1
1 1 1 1 1 1
23
I0 I1 I2
Another scheme of address decoding. Use 3-to-8 demux (decoder) and4-input NAND to decode address bus
24
input address is F8H, where O0 will be active and LED will display the content of accumulator
FAH, where O2 will be active in this case and the buffer will channel the keyed data into the accumulator
26
Interesting Question: Can an input port and an output port have the same port address? Answer:
Another Interesting Question: How will the port number be affected if we decode the high-order address lines A15-A8 rather than A7-A0? Answer:
28
Problem:
Design a seven-segment LED output port with the device
address F5H, using a 74LS138 (3-to-8) decoder, a 74LS20 4-input NAND gate, a 74LS02 NOR gate, and a common-anode sevensegment LED
Write instructions to display digit 7 at the port
29
Seven-Segment LED
To display digit "7" at the LED as in figure, the requirements are: Logic "0" is required to turn on a segment because it is a common-anode seven-segment LED To display "7", segments A, B, and C should be turned on The binary code should be:
Data Lines Bits Segments D7 D6 D5 D4 D3 D2 D1 D0 1 1 1 F 1 E 1 D 0 C 0 B 0 A
30
78H
NC G
Interfacing circuit: For output port with address F5H, the address lines A7-A0 should have the following logic:
A71 A6 A5 A4 A3 A2 A1 A0
F5H
We need to use 74LS138, which has only 3 input pins. Therefore, Use A2, A1, A0 as input lines to the decoder. Connect A3 to active low enable (E1)' The remaining lines connect to (E2)' through 4-input NAND gate Output O5 is ANDed with control signal (IOW)' using the NOR gate (negative input AND) to generate pulse to enable the latch.
31
32
Instructions:
MOVI A,78H OUT F5H HLT ;Load seven-segment code in the accumulator ;Display digit 7 at port F5H ;End
34
enable the tri-state buffer Once the tri-state buffer is enabled, the logic levels of the switches i.e. keyed data is placed on the data bus, before placed into the accumulator Closed switch = logic "0" Open switch = logic "1" Input reading is F8H
36
Address lines A4 and A3 are not used, therefore the device can
A6 0
0 0 0
A5 0
0 0 0
A4 0
0 1 1
A3 0
1 0 1
A2 1
1 1 1
A1 0
0 0 0
A0 0
0 0 0
84 H
8CH 94H 9CH
37
Control signals used: (MEMR)' and (MEMW)' This technique is similar to peripheral I/O
*38
2051
2052
00
80
of accumulator to the specified memory register. Here the memory address is 8000H (16-bit) If we connect an output device with this address (8000H), the accumulator contents will transfer to the output device.
39
operation
Use LDA (Load A Direct) instead of STA For memory-mapped I/O, the control signals are
memory read (MEMR)' and memory write (MEMW)' instead of (IOR)' and (IOW)'
40
M1 is for reading Opcode (first byte of instruction) M2 is for reading 2nd byte of instruction, which is the low order
address M3 is for rading 3rd byte of instruction, which is the remaining high order address M4, data are loaded from the accumulator to the data bus and address 8000H are put on the entire address bus (A15-A0)
We can see the difference here. For OUT instruction, the 8-bit
address of device is put on both the A15-A8 and A7-A0 address bus, and either one can be decoded to identify the output device For memory mapped, all the 16 address lines need to be decoded to identify the output device
41
The steps for device selection and data transfer for memory-mapped I/O: 1. Decode the address bus to generate the device address pulse 2. AND the control signal with the device address pulse to generate the device select (I/O select) pulse 3. Use the device select pulse to enable the I/O port For interfacing memory-mapped input device, we can use the similar steps, but use the instruction LDA, and the control signal will be (RD)' rather than (WR)'
42
Memory-mapped I/O is similar to Peripheral I/O in terms of concept The differences are as follows: Memory-mapped I/O 16-bit (MEMR)'/(MEMW)' Peripheral I/O 8-bit (IOR)'/(IOW)'
Characteristics 1.Device address 2.Control signals for Input/Output 3.Instructions available 4.Data transfer 5.Maximum number of I/Os possible 6.Execution speed 7.Hardware requirements 8.Other features
STA; LDA; LDAX; STAX; MOV IN and OUT M,R: ADD M; SUB M; ANA M: etc Between any register and I/O devices Only between I/O and the Accumulator
The memory map (64K) is shared The I/O map is independent of the between I/Os and system memory memory map; 256 input devices and 256 output devices can be connected 13 T-states (STA,LDA) 7 T-sates (MOV M,R) More hardware is needed to decode 16-bit address Arithmetic or logical operations can be directly performed with I/O DATA 10 T-states Less hardware is needed to decode 8bit address Not available
43