
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).
There are a total of 8 tasks that can be configured. The ON INP statement sets the interrupt conditions. The START INP
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, address, m ask, com pare GOSUB 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. During
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 GOSU 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 more slowly. Thus, if a match occur red and remained 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 example below will let you demonstrate the INP task, using a par allel port, a UTB terminal board and clip leads.
10 ON INP 0, 2, 7, 5 GOSUB 60
20 START INP 0
30 PRINT BIN$ (INP (2) )
Komentarze do niniejszej Instrukcji