Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 74
![background image](https://www.manualsdir.com/files/797818/content/doc074.png)
II. SOFTWARE GUIDES - 8. Driver488/DRV
8E. Microsoft C
Personal488 User’s Manual, Rev. 3.0
II-59
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, C does not provide an automatic method of checking for light pen interrupts.
Therefore, a function is needed to check for the interrupt. The function could use the
STATUS
command, but it is much faster to check the interrupt status directly using a BIOS interrupt. The
CKLPINT
(check light pen interrupt) function provided in
IEEEIO.C
uses the BIOS to check for
Driver488/DRV interrupts and returns true (
1
) if one is pending. Interrupts are checked automatically
by the
IEEEWT
routine before sending any data to Driver488/DRV. However,
IEEEWT
does not call
CKLPINT
directly. Instead, it calls the routine that is pointed to by
IEEE_CKI
(
IEEE
check interrupt).
If
IEEE_CKI
points to
CKLPINT
, then
IEEEWT
checks for Driver488/DRV interrupts, but if
IEEE_CKI
points to
_false_
, a function that always returns
0
, then interrupt checking is disabled.
Initially,
IEEE_CKI
does point to
_false_
, and so interrupt checking is disabled. To enable interrupt
checking
IEEE_CKI
must be redirected to
CKLPINT
:
int cklpint();
ieee_cki = cklpint;
Once an interrupt has been detected, an interrupt service routine must be invoked to handle the
interrupting condition. When
IEEEWT
detects an interrupt, it calls the interrupt service routine (ISR).
Just as
IEEEWT
does not call the check-for-interrupt routine directly, it does not call the ISR directly,
either. Instead, it calls the routine pointed to by
IEEE_ISR
(
IEEE
interrupt service routine). If
IEEE_ISR
is set to point to some specific ISR, then that ISR is executed when
IEEEWT
detects an
interrupt. Initially,
IEEE_ISR
points to
no_op
, a function that does nothing. So, unless
IEEE_ISR
is
redirected to another routine, nothing is done when an interrupt is detected. In the
195DEMO
example
program an interrupt service routine, called
isr
, has been provided. So,
IEEE_ISR
must be set to
point this routine for interrupts to be handled properly:
ieee_isr = isr;
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);
}