Com$ tasking – Remote Processing CAMBASIC User Manual

Page 191

Advertising
background image

Event Multitasking - 2

Between each program statement CAM BASIC checks to see if any interrupt flags are set. If so, it branches to the line
number that was specified for that interrupt. T he maximum tim e to service an interrupt is the length of the command
previous to the interr upt. T his is called maximum latency time. It ranges from about 0.2 m illiseconds to 2 milliseconds.

Ther e are a fe w excep tions. The IN PUT and INP UT K EYP AD$ statements w ill ignore inter rupts until the inp ut is
received. The DE LAY statement will prevent a response to an interrupt until the delay period. If the serial output buffer
becomes full, and there are still more characters to put in the buffer, interrupts will not be serviced until all the characters
are in the buffer.

Interrupt Priorities

CAM BASIC does not have an interrupt priority scheme. However, you can lock out a response to an interrupt for critical
program segments with the LOCK com mand.

CAM BASIC allows nesting of interrupts. That means an interrupt service routine can interrupt another interrupt service
routine. If there ar e two inter rupt r outines, A and B, and A has p artly exec uted when B interru pts, B w ill execute to
conclusion and then A will finish. Thus, the routine that occurred last, in effect, has the highest priority.

S in c e t he s eq u en c e o f th e in c om i ng d at a m u s t b e pr e se r v ed , O N C O M $ in te r r up ts a re in te r n al ly s ta c ke d in C A M BA S IC ,
such that each ON COM $ interrupt w ill be handled in its entirety before the next one oc curs. Other types of inter rupts,
such as ON TIC K, c an be nested in side an ON COM $ interr upt.

E v e nt M u lt it a sk in g do e s n o t h a ve a pr i or i ty s ys te m .

COM$ TASKING

ON CO M$ defines a program branch when a task defined by the CONFIG C OM$ statement becomes valid. The syntax
is:

ON C OM$ channel GOS UB line or label
ON C OM$ channel G O S U B

After defining all the parameters with CON FIG C OM$ the ON COM $ activates the task. You can deactivate the task by
executi ng the sa me sta temen t but with out a line n umbe r afte r GO SUB.

Channel 1 is COM 1 and Channel 2 is COM 2.

COM $ Example:
In the following example, the program will branch when 8 characters have been r eceived. The X ON and protocol
functions are disabled. All characters will be echoed.

10 CONFIG COM$ 1,0,8,0,1
20 ON COM$ 1 GOSUB 80
30 ..your program goes here
.
.
80 PRINT COM$(1)
90 RETURN

NOTE:

If a serial reception error occur s, the progr am will branch to line 80 regardless of the number of
characters received. You can use the SYS(6) or SYS(7) function to determine the cause of the error.

Advertising