On inp – Remote Processing CAMBASIC User Manual

Page 120

Advertising
background image

Comm ands - 87

ON INP

Tasking Statement

SYNTAX:

ON INP n, address, mask, compare GOS UB line/label

PURPOSE:

To cause an interr upt when a preset inpu t bit pattern is de tected in an inpu t port.

REMARK S:

The task is similar to ON BIT. However, you can look at any or all of the 8 bits on a port. An
interrupt occurs when the bit pattern is recognized.

The interrupt will occur on the first instance of the pattern match. It will not interrupt again until the
inputs change and then change back to match the pattern. This is sometimes called an “edge
triggered” mode.

The parameter n is the task number. It ranges from 0 to 7.

The address is the I/O address of the port to be read.

The mask parameter determines which bits are of interest. Each bit in the mask that is a “ 1” is a bit
of interest.

When the data at the port matches the compare parameter, an interrupt occurs and the program
branches to the line/labe l. Up to 8 con ditions may be tested on the sa me por t or differ ent ports

See the Multitasking Chapter for more information.

RELATED:

S T A R T I N P , S T OP I N P

EXAMPLE:

10 ON INP 0,3,7,5 GOSUB 60
20 START INP 0
30 PRINT BIN$(INP(0))
40 DELAY .25
50 GOTO 30
60 PRINT "match"
70 RETURN

ERROR:

< Data negative> – all parameters
< Data out of range> – if n> 7
< Data > 255> – for mask and compare
< Data > 65,535> – for address
< Can’t compile> – if line/labe l not found

Advertising