beautypg.com

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

Page 109

background image

8J. Spreadsheets

II. SOFTWARE GUIDES - 8. Driver488/DRV

II-94

Personal488 User’s Manual, Rev. 3.0

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, Lotus 1-2-3 does not provide an automatic method of checking for light pen status.
Therefore, a subroutine is needed to check for the interrupt. This subroutine uses the

SPOLL

command

to check for

SRQ

:

CheckSRQ:
{DEFINE Signal:VALUE}
{WRITELN SPOLL}
{READLN SP}
{LET SP,@VALUE(@MID(SP,0,@LENGTH(SP)-1))}
{IF SP=0}{BLANK ST195}{RETURN}

The

CheckSRQ

takes a numeric parameter,

Signal

, which can be used to note where in the program

the interrupt occurred. The subroutine begins by reading the response to the

SPOLL

command and

converting that response to a numeric value,

SP

. If

SP

is zero (

0

), then no

SRQ

is pending and we clear

the 195 status cell,

ST195

, and then return. If SP is non-zero, we know that an

SRQ

is pending.

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 “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 check for service requests by calling

CheckSRQ

at appropriate places in the program. The only

place

CheckSRQ

should not be used, is between a command that requests a response, such as

STATUS

or

ENTER

, and the statement(s) that read that response. The

CheckSRQ

parameter,

Signal

can be used

to identify where the interrupt was detected. A typical sequence might be:

{WRITELN “STATUS”}
{READLN Status}
{CheckSRQ 10}
{WRITELN ENTER 16}
{READLN Reading}
{CHECKSRQ 20}

Once

CheckSRQ

has determined, with a Serial Poll, that a service request is indeed pending, it then

checks the 195 to determine if it is the source of the interrupt. 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.

{WRITELN SPOLL 16}
{READLN ST195}
{LET ST195,@VALUE(@MID(ST195,0,@LENGTH(ST195)-1))}~

The tilde (~) at the end of the

LET

statement forces evaluation of the spreadsheet. In particular, it

causes the values of the cells

DIO8

through

DIO1

to be set to the values of the bits of

ST195

. These

cells can then be examined to inspect the 195’s status:

{IF DIO7}{BRANCH 195SRQ}
{BEEP}{GETLABEL “Non-195 SRQ detected! Press Return.”,TypeHere}
{RESTART}{RETURN}

Bit

DIO7

, 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 it is not, there must

be some error. If

DIO7

is set, we

BRANCH

to

195SRQ

and continue with the subroutine. Otherwise we

BEEP

, display an error message, and terminate macro execution.

TypeHere

is a blank cell that holds

anything that is typed by the user before the return

is pressed.