HP IBASIC Supplement 8-13
Interfacing with External Devices
General Bus Management
GPIB Service Reqsts
Most GPIB devices, such as voltmeters, frequency counters, and
analyzers, are capable of generating a “service request” when they
require the active controller to take action. Service requests are
generally made after the device has completed a task (such as making a
measurement) or when an error condition exists (such as a printer being
out of paper). The operating and/or programming manuals for each
device describe the device's capability to request service and conditions
under which the device will request service. To request service, the
device sends a Service Request message (SRQ) to the active controller.
The mechanism by which the active controller detects these requests is
the SRQ interrupt. Interrupts allow an efficient use of system resources,
because the system may be executing a program until interrupted by an
event's occurrence. If enabled, the external event initiates a program
branch to a routine which “services” the event by performing some
action.
Setting Up and Enabling SRQ Interrupts
In order for an GPIB device to be able to initiate a service routine in the
active controller, two prerequisites must be met: the SRQ interrupt event
must have a service routine defined, and the SRQ interrupt must be
enabled to initiate the branch to the service routine.
The following program segment shows an example of setting up and
enabling an SRQ interrupt.
100 Hpib=7
110 ON INTR Hpib GOSUB Service_routine
120 !
130 Mask=2
140 ENABLE INTR Hpib;Mask
Since IBASIC recognizes only SRQ interrupts, the value assigned to the
mask is meaningless. However, a mask value may be present as a
placeholder for compatibility with HP Series BASIC programs.