Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 93
8H. Turbo C
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-78
Personal488 User’s Manual, Rev. 3.0
Once we have enabled interrupt checking by setting
IEEE_CKI
to point to
CKLPINT
, and specified the
interrupt service routine by setting
IEEE_ISR
to point to
isr
, then we can specify which conditions are
to cause an interrupt. The
ARM
command specifies those conditions. In this example we want the
interrupt to occur on the detection of a Service Request (
SRQ
):
ieeewt(“arm srq\n”);
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:
ieeewt(“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 that interrupt detection is enabled, and the interrupt service routine is specified, we must specify
the actions to take to service the interrupt. We first display a message indicating that an interrupt was
detected, and then turn off interrupt checking:
void isr()
{ int _false()_;
printf(“Interrupt detected...”);
ieee_cki = _false_;
We next check the Driver488/DRV Serial Poll Status to determine if an
SRQ
actually caused the
interrupt:
int sp;
ieeewt(“spoll\n”);
ieeescnf(“%d”,&sp);
if (sp==0) {
printf(“Non-SRQ Interrupt!\n”);
exit(1);
}
We then 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.
int st195;
ieeewt(“spoll 16\n”);
ieeescnf(“%d”,&st195);
if ((st195 & 0x40) == 0 ) {
printf(“Non-195 SRQ!\n”);
exit();
}
Bit
DIO7
, with a value of
0x40
, is returned as true (
1
) in the Serial Poll response of those devices
requesting service. In our simple example we expect that the 195 is the only possible cause of an
SRQ
,
and if not, there must be some error.
Now that we have identified the device that is requesting service, we can further examine the Serial
Poll status to classify the request:
if ((st195 & 0x20) == 0) {
if (st195 & 0x01)
printf(“Overflow\n”);
if (st195 & 0x02)
printf(“Buffer Full\n”);
if (st195 & 0x04)
printf(“Buffer 1/2 Full\n”);
if (st195 & 0x08)
printf(“Reading Done\n”);
if (st195 & 0x10)
printf(“Busy\n”);
} else {
if (st195 & 0x01)
printf(“Illegal Command Option\n”);
if (st195 & 0x02)