
7-6
Section
Details of BASIC Commands
184
on timer
Syntax:
ON TIMER
<time expression>
GOSUB
(<line number> | <label>)
Description:
Statement. Defines an interrupt subroutine to handle recurring timer interrupts.
When the specified time has elapsed after execution of
ON TIMER
, program execution branches to
the specified interrupt subroutine. After completion of the interrupt subroutine, the timer is reset
and the subroutine will be executed again after the specified time has elapsed. The subroutine will
be executed repeatedly until the
TIME OFF
statement is executed.
Remarks:
<time expression> is an integer expression with a result in the range : [1…864000].
The units specified in the time expression are 0.1 seconds. This gives a total alarm range of 24
hours.
<line number> specifies the start of the interrupt subroutine (ISR).
<label> is a BASIC program label. It references a line number somewhere in the BASIC program.
The timer interrupts are enabled by the
TIMER ON
statement and disabled by the
TIMER OFF
statement. The
TIMER STOP
statement masks and enables the timer interrupts so the interrupts are
recorded but the ISRs are not executed until the next
TIMER ON
statement unmasks the interrupts.
The ISR should be terminated by a
RETURN
statement. When the
RETURN
statement is reached,
execution will resume at the statement where the program was interrupted.
Timer interrupts are decrementing timer interrupts. The timer begins counting down from the time
specified in the timer statement. When the timer reaches zero, program execution branches to the
defined interrupt subroutine as long as the interrupt is enabled (not masked).
Timer interrupts are “repetitive” interrupts. The timer interrupt remains valid after program
execution has branched to the specified ISR, so the same ISR will be executed repeatedly each
time that the timer counts down to zero. The timer interrupts will repeat until they are disabled
with the
TIMER OFF
statement, thus these are interval timer interrupts. In this sense, timer
interrupts are unlike the alarm interrupts, which are “one-shot” interrupts.
Examples:
> 5 T = 0
> 10 ON TIMER 300 GOSUB 100
> 20 TIMER ON
> 30 GOTO 30
> 100 T = T+300
> 110 PRINT T; “ MILLISECONDS HAVE ELAPSED SINCE THE START OF
EXECUTION.”
> 120 RETURN
See also:
TIMER
(
ON
|
OFF
|
STOP
)
Содержание C200H-ASC11
Страница 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Страница 2: ...iv...
Страница 4: ...vi...