
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 requires that CONF IG COU NT, ON COUNT 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 automatically rese t.
Line 20 directs CAM BASIC to branch to a subroutine when the preset count is reached.
Line 30 starts counter operation. These three lines do not need to be adjacent in the program.
However, they must be executed in this order.
Line 200 increments variable A. Thus, the value of A is the number of times the counter has
counted to 2000.
Line 210 returns program 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.
Commenti su questo manuale