CS-480A, Lab # 3
Simple I/O Ports
9-25-02 and 10-3-02
Due Date: 10-10-02

In this lab you will learn how to interface simple I/O ports to the 8086
microprocessor. Specifically you will design simple 4-bit input and output 
ports for the SDK-86. These will be implemented on a prototyping board that 
is connected via ribbon cables to 8086 signal lines on the SDK-86. Once you 
have set up your I/O ports, you will connect the input port to four dip 
switches, and the output port to four Light Emitting Diodes (LEDs). You will 
write software that will continually read the state of the DIP switches and 
turn on the LEDs corresponding to the switches that are in the "on" position.

The various 8086 bus signals are available on connectors J1, J2, and J3 on
the SDK-86. These signals may be brought out to a prototyping board using
ribbon cables. All the existing I/O addresses decoded and used by the SDK-86
board require that the address bits A5-A10 be high. Therefore, for our port
address decoding it is sufficient to use address 00h for both the input and 
output ports and require a single address bit (say A7) be low. (This simple
decoding scheme means that our I/O ports will respond not only to address 00h 
but to any I/O address in which A7 is 0. The RD* and WR* signals from the 
microprocessor may be used to distinguish input bus cycles from output bus 
cycles, and the MEM/IO* signal can be used to differentiate I/O bus cycles 
from memory bus cycles. These signals can be combined suitably using NAND/NOR 
gates to select the input or output port. You will need to devise the 
decoding circuits that do that selection. Figure 1 shows the pin numbers 
corresponding to each 8086 bus signal on SDK-86 connectors J1, J2, and J3, 
and what pin numbers they are mapped to on the prototyping board connectors 
P1, P2, and P3.

Figure 1. SDK-86 Breadboard Connectors

A 4-bit tristate buffer (e.g., the 74126 quad tristate buffer) can be used as 
the input port. On the SDK-86 prototyping board wire up an 8-pin set of DIP 
switches as shown in Figure 2. You will only use four of the eight switches 
for this experiment. The enable signals to the buffer will come from the 
circuit you devised to select the input port in response to a port 0 input 
action. Be sure to conect +5 V and ground leads from P2 on the SDK-86 to the 
74126 tristate buffer. Pinouts for the 74126 are given in Figure 3.

Figure 3. Pinouts for the 74126 tristate buffer

A 4-bit latch (e.g., the 7475 quad transparent D Latch) can be used as the 
output port. In a different area of the breadboard, wire up four LEDs to the 
7475 latch as shown in Figure 4. If your packet does not contain a 7407 hex 
buffer, you should use a 7417, which is equivalent. Be sure that you get the 
polarity of the LEDs right. (The flat side of the LED with the shorter of 
the two wires is the cathode--the side that corresponds to the vertical line 
and NOT the triangle on the LED schematic symbol.) This is very important, 
since if you wire the LEDs backwards, they could literally blow up on you!! 
The E12 and E23 signals to the latch will come from the circuit you devised 
to select the output port in response to a port 0 output action. Be sure  to 
conect +5 V and ground leads from P2 on the prototype board to the 7475 
latch. Pinouts for the 7475 are given in Figure 5 and those of the 7407/17 in 
Figure 6.

Figure 5. Pinouts for the 7475 Quad D Latch

Figure 6. Pinouts for the 7407 Quad Hex Buffer

The software

1. Write a program that will turn off all of the LEDs, and then continually read 
the switches and send its bit pattern to the output port, thereby displaying 
it on the LEDs. Note from the circuit diagrams that an input bit will be low 
when a switch is closed, and that an LED will be lit when its bit from the 
output port is also low. If things are working properly, every time a switch 
is changed, the corresponding LED should reflect the new state of the switch.

2. Write another program that does different things when different switches are
closed. Specifically: if the switch that's connected to D0 is closed, all the LEDs
should be turned off; if the one connected to D1 is closed, all the LEDs should
be turned on; if the one connected to D2 is closed, the LEDs should simultaneously
blink on and off; if the one connected to D3 is closed, the D0 LED should be lit
and turned off, then the D1 LED, then the D2, LED, then the D3 LED. This action
should continue until a different switch is closed. For this part you may assume
that only one switch at a time is closed.
Demonstrate to the lab instructor that everything is working correctly.

Lab Report

Your lab report should contain the detailed circuit diagrams of your I/O ports 
and decoding logic as well as an assembled listing  (.LST) of your program.