Remote Processing CAMBASIC User Manual

Page 194

Advertising
background image

Event Multitasking - 5

The second is the interrupt mode. When the preset count is reached, a software interrupt is generated and the program
branches to a subroutine which acts on the preset count. This mode requir es that CONF IG COU NT, ON C OUN T and
START COUNT be executed in that order. Below is a short example of a prescaler:

10 CONFIG COUNT 5,0,1,2000,AUTO
20 ON COUNT 5 GOSUB 200
30 START COUNT 5
.
.
200 INC A
210 RETURN

Line 10 configures counter 5 to read bit 1 of address 0 as an input. When the count reaches 2000,
the counter will autom atically rese t.

Line 20 directs CAM BASIC to branch to a subroutine when the preset count is reached.

L i ne 3 0 s ta r ts c ou n te r o pe r a ti on . T h es e th r e e l in e s d o no t n e ed to b e a d ja c en t i n t he p r og r a m .
However, they must be executed in this order.

Line 200 increments variable A. T hus, the value of A is the number of times the counter has
counted to 2000.

Line 210 returns progr am execution to the place that it was interrupted.

It is imperative that the counter numbers in CONF IG COU NT and STA RT count match. Otherwise, operation will be
unpredictable.

Advertising