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

8I. Turbo Pascal
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-88
Personal488 User’s Manual, Rev. 3.0
Serial Poll, though it is not as fast as Parallel Poll, does offer three major advantages: it gives an
unambiguous response from a single bus device; it returns additional status information beyond the
simple request/no-request for service; and, most importantly, it is implemented on virtually all bus
devices.
The
SRQ
line can be monitored in two ways: it can be periodically polled using the
STATUS
command,
or it can be used to cause an external interrupt when asserted.
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.
Unlike BASIC, Turbo Pascal does not provide an automatic method of checking for light pen status.
Therefore, a procedure is needed to check for the interrupt. The procedure could use the
STATUS
command, but it is much faster to check the interrupt status directly, using a BIOS interrupt:
PROCEDURE CheckInt(Signal:integer);
BEGIN
Regs.AX=$0400;
{Function 4, check light pen status}
Intr($10,Regs); {BIOS interrupt $10}
WHILE Registers.AH 0 DO BEGIN
{A Driver488/DRV interrupt has occurred}
{Take the appropriate action}
Regs.AX=$0400;
{Check if another interrupt has occurred}
Intr($10,Regs);
END
END; {of procedure CheckInt}
Inside the
WHILE
loop, where
Registers.AH
is not zero, we know that a Driver488/DRV interrupt
has occurred. The
ARM
command is used to specify which conditions should cause that interrupt. In
this example we want the interrupt to occur on the detection of a Service Request:
Writeln(IeeeOut,’ARM SRQ’);
The 195 can be set to request service on any of several different internal conditions. In particular, the
M2
command causes an
SRQ
upon the detection of any invalid command or command option by the
195:
Writeln(IeeeOut,’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.
Now we can check for interrupts by calling
CheckInt
at appropriate places in the program. The only
place
CheckInt
should not be used, is between a command that requests a response, such as
STATUS
or
ENTER
, and the statement(s) that reads the response. The
CheckInt
parameter,
Signal
, can be
used to identify where the interrupt was detected. A typical sequence might be the following:
Writeln(IeeeOut,’STATUS’);
Readln(IeeeIn,Response); CheckInt(10);
Writeln(IeeeOut,’ENTER 16’);
Readln(IeeeIn,Reading); CheckInt(20);
Each time
CheckInt
is called, Driver488/DRV interrupts are checked. Now we must specify what
action should be taken when an interrupt is detected.
Upon detecting an interrupt, we first display a message indicating that an interrupt was found, and then
check the Driver488/DRV Serial Poll Status to determine if an
SRQ
actually caused the interrupt: