Hardware Interfacing with the Apple II Plus
From the originals
29 scansMachine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.
These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.
PDF page 25
,.._ ______ ___ 1 read cycle - - -------+I I 1 μs I I I l~ __/ \ I 1'----- <PO I I : I Address of memory cell or 1 /0 device becomes valid I - AO-A1- siX~~~~~~~ !X~- 1 I J I R/W switches high I I ~ I I I _R _ IW _ -~___, i~/i : I I I I I I I I Valid data from memory or 1 / 0 appears I I I _ 0 0-01_ ! ---+- i ___ ___, )\'---~ i_)C I I i---- -- Memory read access time --- - 1 (al 14-- --- ----- 1 write cycle - --- --- - - +i I 1 μs I - --""' ' I \ .____ __ ~/ \ ,,_____ I I ! I Address of memory cell or 1 /0 device becomes valid l - Ao - A15 iX'------ i x= R/W I I I I I I I \f R AV sw itches low I I I Da ta to memory or 1 / 0 appears _ oo _ -_ 01~-r-~~~~~~~~~~----'~ I I ! Y:_ (bl Figure 1-3 Ill ustrating me mo ry read (a ) a nd m em ory write (b ) machine cycles. In both cases t he trans fer of data occurs over th e dat a bus a nd is synchronized wi th t he logic 1 level o f <l>O. 17
Reading notes: Timing diagram labels and signal names are garbled in places, including the 'AO-A1' and 'Ao - A15' address lines and the 'R/W' and 'RD' signal labels. Reading order of the two machine-cycle diagrams (a) and (b) is uncertain due to fragmented text. Figure caption text at the end is partially broken across line breaks.
- Languages
- English
PDF page 26
18 Experiment 1 Types of 1/0 In general, a microprocessor may interface with its I/0 devices in two ways. In the first, called 110-mapped J/0, the microprocessor must use special in- put (INP) and output (OUT) commands. For example, data is input with a BASIC command such as 10 Y'flNP(47) or output with a command such as 10 OUT 47,Y In the first case the variable Y receives the data from port 4 7, whereas in the second case the variable Y is output to port 4 7. Unfortunately, the 6502 microprocessor (and therefore the Apple computer) does not support this type of 1/0. This is a design feature of the microprocessor itself and cannot be changed. For this reason Applesoft does not allow the INP and OUT commands. The second type of I/0 is called memory-mapped J/ 0 . In this scheme I/O devices are interfaced so as to appear to be memory locations and the full 16-bit address bus is used. In this case, any command that reads or writes to memory becomes an I/0 instruction. In BASIC there are just two. For example, to read the contents of port 26128, we would use 10 Y=PEEK(26128) Similarly, to write the contents of Y to this same port we would use 10 POKE 26128, Y The experiments to follow will give more detail on how to use these PEEK and POKE commands with memory-mapped I/0 devices. PROCEDURE Step 1. Refer to Appendix A and wire your Vector card according to the instructions given there. Now insert the card into the Apple slot 7. The cable should exit to the left when viewed from the front of the Apple. See Fig. I-2 for the proper orientation. Step 2. Because all the experiments require connections to the socket end of the ribbon cable, it will be best to secure this end of the cable to your breadboard. Refer to Fig. I-3. The breadboard sockets have been offset just slightly, allowing t inch of the "stickum" on the base to be exposed. This, in
Reading notes: Page header and figure references may have OCR artifacts such as '18 Experiment 1' and 'Types of 1/0' with irregular spacing. Source ends mid-sentence at 'This, in'.
- Languages
- English
PDF page 27
Experiment l 19 turn, is used to hold the socket end of the cable in place. Figure 1-4b illus- trates the proper orientation and the resulting pin number configuration for the socket connector. Step 3. Connect a short wire from pin 1 of the socket connector to one of the bus strips on the breadboard (label this strip +5 V). Connect a sec- ond piece of wire from pin 40 to a second bus strip (label this ground). Now connect a 10-μF capacitor(+ lead to +5 V) between the two bus strips. Note. Your breadboard is now in its pennanent configuration and ready to per- fonn all the experiments in this book. Step 4. Refer to Fig. 1-4a and wire this circuit on your breadboard. Figure 1-4b illustrates the proper method for inserting the !Cs. Please be sure to observe the following: 1. Position the two !Cs so that they straddle the center notch of the breadboard (see Figs. 1-3 and 1-4b). 2. The !Cs must have power; +5 V on pin 14 (7400) and pin 5 (7476). Be sure also to connect the grounds: pin 7 (7400) and pin 13 (7476). 3. Connect the LED with the lead from the flat side of the package to pin 15 of the 7476. Connect a 180-U resistor (brown-gray-brown) from the other LED lead to the +5 V bus strip. 4. Connect a wire from pin 37 (4>0) of the socket connector to pin 1 of the 7400. Connect pin 38 (R/W) to pin 2 of the 7400. Note. When <l>O AND R/W are both high {a valid memory read cycle) the 7400 out- put will go low. This will act as a clock pulse to the 7476, which is wired in the toggle mode {refer to Appendix E for a review of the JK flip-flop). Each time a memory read occurs, the 7476 will switch states and the LED will toggle ON and OFF. Step 5. Type and run the following program and observe the LED. 10 Y=PEEK(26128) 20 GOTO 10 Question 1-1. The LED should appear to be brightly lit. Can you ex- plain why? (Hint: Remove and replace the wire to the 7476 clock input (pin 1) several times. You should see that the LED brilliance dims slightly when the connection is made. Also, when the wire is removed the LED may be ON or OFF, proving that the output is switching. If you have a logic probe or oscilloscope you can monitor the flip-flop input and output pins and observe this pulse condition.*) "'Answers to all questions are provided at the end of each experiment.
Reading notes: Pin reference '4>0' appears to be an OCR rendering of the Φ0 clock signal and is uncertain. Resistor value '180-U' likely means 180-ohm; the unit symbol is damaged. Capacitor value '10-μF' and the 'Experiment l' heading were read from degraded copy.
- Printed product names
- 7400 · 7476 · 4>0 · R/W
- Languages
- English
PDF page 28
<l>O R/ W Socket connector +5v - GND- 0 20 +5 v Flat side of LED package 2 PR 15 +5 v Q +5 v 4 7 4 7 3 6 7400 Q 14 +5 V K CL 16 3 IC +5 v GND +5 v 7400 14 7 7476 5 13 (al Ribbon cable assembly 20 19 21 22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7476 8 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) 0 0 0 0 0 0 · ~ 10 μF 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - (b) Figure 1-4 Circuit to be w ired in step 4 of t he experiment: (a) schematic repre- sentation; (b) pictorial view of the breadboard and ribbon cable assembly.
Reading notes: Circuit diagram labels and pin numbers are fragmented and reading order is uncertain. Some characters in the ribbon cable and breadboard grid are garbled or ambiguous.
- Printed product names
- 7400 · 7476
- Languages
- English
PDF page 29
Experiment l 21 Figure 1-5 The circuit in Fig. 1-4 is modified to monitor memory write cycles by first inverting the R / W line and then connecting to the 7400 pin 2 in Fig. 1-4. Step 6. Try to slow down the program by adding a new line 15. 15 FOR l =l TO 1000 : Next I Question 1-2. Why is the LED still continually lit? Step 7. By inverting the R/W line, the circuit in Fig. 1-4 will toggle for memory w rite cycles. Figure 1-5 illustrates the circuit modification. Make this change and then type and run the following program: 10 POKE 261 28,0 1 5 FOR l =l TO 1000: NEXT I 20 GOTO 10 Question 1-3. What do you observe? No te. Although this experiment did not do anything very impressive, we did learn an important lesson. You cannot interface 1/0 devices to the microcomputer by simply monitoring for read or write machine cycle types. In Experiment 2 we will see how the use of an address decoder will allow us to detect special read or write cycles for our 1/ 0 device. The 7476 portion of this circuit will be used again in the next experiment. Step 8. Reread the objectives listed at the beginning of this experi- ment. If these points are not clear to you, restudy the "Discussion" and "Procedure" sections. ---- -- SOLUTIONS TO QUESTIONS 1-1. The memory reads occur so rapidly that your eye cannot detect the LED switching on and off. 1·2. The microprocessor is continually accessing memory for operation codes and data (in addition to the PEEK command), causing thousands of memory reads each pass through the program. In fact, because every microprocessor instruction must begin with an op-code fetch (a memory read), the circuit in Fig. 1-4 will always have the LED brightly lit and not slowly switching on and off. This will even be true when the program is not running. Push the RESET key to observe this. 1-3. Again the LED is continually lit. Many memory write cycles also occur in a single pass through the program in addition to the memory write due to the POKE command.
Reading notes: Figure and pin references (Fig. 1-4, pin 2) are present in the copy but no image was supplied to verify them.
- Printed product names
- 7400 · 7476
- Languages
- English