Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 85

8G. QuickBASIC
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-70
Personal488 User’s Manual, Rev. 3.0
BASIC provides a method for detecting and servicing external interrupts: the
ON PEN
statement. The
ON PEN
statement tells BASIC that, when an external interrupt is detected, a specific subroutine,
known as the interrupt service routine (ISR), is to be executed. Normally, the interrupt detected by
ON PEN
is the light pen interrupt. However, Driver488/DRV redefines this “light pen interrupt” to
signal when an IEEE 488 bus related interrupt (such as
SRQ
) has occurred.
When Driver488/DRV detects an interrupt, it informs the user’s program that an interrupt has occurred
by making it appear that a light pen interrupt has occurred. To allow BASIC and Driver488/DRV to
work together to detect and service the interrupt, the following steps are required:
1.
BASIC must be told which subroutine to execute upon detection of the interrupt.
2.
BASIC interrupt detection must be enabled.
3.
Driver488/DRV must be configured to detect the interrupt.
The
ON PEN GOSUB
,
PEN ON
, and
ARM SRQ
commands, respectively, perform these steps:
250 ON PEN GOSUB ISR
260 PEN ON
270 PRINT#1,"ARM SRQ"
1.
The
ON PEN GOSUB
command tells BASIC that the subroutine called
ISR
is to be executed when
the light pen interrupt is detected. Driver488/DRV causes the light pen interrupt to occur on
detection of an IEEE 488 interrupt.
2.
The
PEN ON
command enables the actual checking for light pen interrupt status.
3.
The
ARM SRQ
command tells Driver488/DRV that an interrupt is to be signaled on detection of a
service request from the IEEE 488 bus.
These commands are placed near the beginning of the program to catch Service Requests (
SRQ
)
whenever they occur.
The 195 can be set to request service on any of several different internal conditions. In particular, the
M2
command causes an
SRQ
on the detection of any invalid command or command option by the 195:
550 PRINT#1,"OUTPUT 16;M2X"
This
OUTPUT
command is placed early in the program so that all subsequent commands to the 195
cause an
SRQ
, if they are invalid.
At this point BASIC is checking for an interrupt, and knows to
GOSUB SRQ
when an interrupt is
detected. Driver488/DRV is set to generate an interrupt on detection of an SRQ generated by the 195
on detection of an invalid command. We must still, however, specify what action should be taken once
an interrupt is detected.
Upon entering the interrupt service routine, we first check Driver488/DRV to see if it is ready for a
command and if so, read the Serial Poll Status to determine if an
SRQ
actually caused the interrupt:
2000 SRQ: ‘Interrupt service routine—Entered due to SRQ
2010 ‘
2020 ‘RETURN if Driver488/DRV is not ready for commands.
2030 IF IOCTL$(2)"0" THEN RETURN
2040 ‘
2050 ‘Check that it is indeed an SRQ
2060 PRINT#1,"SPOLL"
2070 INPUT#2,SP
2080 IF SP=0 THEN PRINT “Non-SRQ Interrupt!”: STOP
Next we Serial Poll the 195 to determine its status. If there were other devices on the bus that could be
generating the
SRQ
, each of them would be have to be checked in turn.
2110 PRINT#1,"SPOLL 16"
2120 INPUT#2,ST195
2130 IF (ST195 AND 64) = 0 THEN PRINT “Non-195 SRQ!”: STOP