beautypg.com

Interrupt handling – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 92

background image

II. SOFTWARE GUIDES - 8. Driver488/DRV

8H. Turbo C

Personal488 User’s Manual, Rev. 3.0

II-77

Interrupt Handling

The IEEE 488 bus is designed to be able to attend to asynchronous (unpredictable) events or
conditions. When such an event occurs, the bus device needing attention can assert the Service
Request (

SRQ

) line to signal that condition to the controller. Once the controller notices the SRQ, it can

interrogate the bus devices, using Parallel Poll (

PPOLL

) and/or Serial Poll (

SPOLL

) to determine the

source and cause of the

SRQ

, and take the appropriate action.

Parallel Poll is the fastest method of determining which device requires service. Parallel Poll is a very
short, simple IEEE 488 bus transaction that quickly returns the status from many devices. Each of the
eight IEEE 488 bus data bits can contain the Parallel Poll response from one or more devices. So, if
there are eight or fewer devices on the bus, then just the single Parallel Poll can determine which
requires service. Even if the bus is occupied by the full complement of 15 devices, then Parallel Poll
can narrow the possibilities down to a choice of no more than two.

Unfortunately, the utility of Parallel Poll is limited when working with actual devices. Some have no
Parallel Poll response capability. Others must be configured in hardware, usually with switches or
jumpers, to set their Parallel Poll response. If Parallel Poll is not available, or several devices share the
same Parallel Poll response bit, then Serial Polling is still required to determine which device is
requesting service.

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 by using the

STATUS

command, or by checking the “light pen status.”

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, 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;