Inp tasking – Remote Processing CAMBASIC User Manual

Page 196

Advertising
background image

Event Multitasking - 7

Line 110 prints the count in the counter.

Line 120 returns execution to the place where the one– second interrupt occurred.

You can try this by holding down the < ENTER> on your terminal so that it auto– repeats and enters count faster.

INP TASKING

INP tasking lets you react to a combination of on/off conditions at a digital I/O port. T hat is, you may want to detect
when inputs 0, 1 and 7 are high, and inputs 2 and 3 are low, while ignoring the other input lines (4, 5, 6).

T h e re a r e a to ta l o f 8 t as k s t ha t c a n b e co n fi gu r e d. T h e O N IN P s ta t em e n t s e ts th e in te r r up t c o nd it io n s. T h e ST A R T IN P
is used to activate the task. STOP INP will deactivate the task. Another STA RT INP will reactivate the task. You do not
need to execute ON INP to start the task again.

Declaring a Task

This is done with the ON INP statem ent. T he syntax is :

ON INP n, addre ss, m ask, com pare G O S U B line/label

Where:
n is the task number. The r ange of n is 0 to 7.

address is the I/O address of the port in interest. The port can be an actual input port like that on an
82C55, a readable latch or an internal CPU register.

mask determines which of the input bits or lines are of interest. For example, if we want to look at
lines 0, 1, 2, 3 and 7, then the mask would be:

10001111

in binary or 8F in hex or 143 in decimal. The “1” bits of the mask are the bits of interest. D uring
execution the mask is ANDed with the port value.

If the result is equal to the compare parameter, then a interrupt occurs. The program then branches
to the G OSU B line/label.

The inputs are checked 200 (100 in 9 MHz systems) times per second. In most applications, the inputs will be changing
much m ore slowly. Thus, if a match occur red and r emained the sam e for one second, then 200 (100 in 9 MH z systems)
interrupts would occur.

To prevent this from happening, the ON INP operates in the “edge triggered” mode. The program branch occurs only on
the first instance of the match. All subsequent matches are ignored until at least one input changes, so that a match is not
present.

The exam ple below will let you dem onstrate the INP task, using a par allel port, a UTB ter minal board a nd clip leads.

10 ON INP 0, 2, 7, 5 GOSUB 60
20 START INP 0
30 PRINT BIN$ (INP (2) )

Advertising