27.01.2015 Views

titus-larsen-titus-1981-apple-interfacing

titus-larsen-titus-1981-apple-interfacing

titus-larsen-titus-1981-apple-interfacing

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Yes. Simply reverse the commands at lines 60 and 80. You can easily<br />

"invert" the sense of a flag in software.<br />

In this step, you will use a short program that will count the<br />

number of times that the flag is set. Again, the assembly-language<br />

subroutine will be used. You may wish to add another pulser circuit<br />

to provide the flag-clearing operation to replace the jumper wire<br />

between pin 1 on the SN7474 and +5 volts.<br />

Enter the following program and run it:<br />

POKE 10,76: POKE 11,3: POKE 12,3<br />

POKE 768,l<br />

HOME: C = 0<br />

POKE 769, PEEK(49319)<br />

Z = USR(O)<br />

IF PEEK(770) = 0 THEN 40<br />

C = C+l: HTAB l: VTAB l: PRINT C<br />

GOTO 40<br />

Be sure that the Hip-flop is cleared before you test the program.<br />

With the program running, actuate the pulser and set the Hip-flop.<br />

hat do you observe Is this what you expected<br />

We found that the count started as soon as the flip-Hop was set, and<br />

that it continued for as long as the Hag remained set. Clearing the<br />

'p-flop stopped the count. What we really wanted was one count<br />

.each time the flip-Hop was set.<br />

·· Why didn't this happen as expected The set state of the Hip-flop<br />

eontinued to be tested and detected by the program. We could not<br />

reset the flip-Hop fast enough by hand to stop the counting at one<br />

count per pulser actuation.<br />

In most computer systems, the computer, or the flag-containing<br />

.device clears the flag after it has been detected. To allow your interface<br />

to clear the Hip-flop, add the circuit shown in Fig. 6-22. Y-ou will<br />

need an SN7402 NOR-gate chip. Be sure,that you wire the' +5-volt<br />

ower supply to pin 14, and ground to pin 7, on the SN7402 chip.<br />

Since the NOR-gate circuit will provide the rese t signal for the Hip-<br />

153

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!