
7-6
Section
Details of BASIC Commands
177
on alarm
Syntax:
ON ALARM
<time expression>
GOSUB
(<line number> | <label>)
Description:
Statement. An interrupt is generated after the specified time elapses. When the specified time has
elapsed after execution of
ON ALARM
, program execution branches to the interrupt subroutine at
the specified line number.
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 ISR should be terminated by a
RETURN
statement. When the
RETURN
statement is reached
execution will resume at the statement after the statement that was originally interrupted.
ALARM
interrupts are decrementing timer interrupts. The timer begins counting down from the
time specified in the
ON ALARM
statement. When the timer reaches zero, program execution
branches to the defined interrupt subroutine.
The
ALARM
interrupts are one-shot interrupts. Once program execution has branched to the
specified interrupt subroutine, the
ALARM
interrupt is invalid and another interrupt will not occur
until another
ON ALARM
statement is executed and its specified time elapses. In this sense,
ALARM
interrupts are unlike the
TIMER
interrupts, which are “repetitive” interrupts.
Only one
ON ALARM
interrupt can be valid at any one time. If two or more
ON ALARM
statements
are set in a single program, only the last
ON ALARM
statement’s interrupt will be valid.
While the
ALARM
interrupt subroutine is being executed, other incoming interrupts will be
recorded but not executed. These stopped interrupts will be executed in order of their priority after
the
ALARM
interrupt subroutine has been completed.
For more information on writing interrupts in BASIC, refer to 5-5 Interrupt Functions.
Examples:
> 10 A=0
> 20 ON ALARM 30 GOSUB 1000
> 30 ALARM ON
> 40 IF A=0 THEN GOTO 40
> 50 PRINT “END”
> 60 END
> 1000 PRINT “INTERRUPT OCCURRED”
> 1010 A = 1
> 1020 RETURN
> RUN
INTERRUPT OCCURRED
END
See also:
ALARM
(
ON
|
OFF
|
STOP
),
ON TIMER
Содержание C200H-ASC11
Страница 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Страница 2: ...iv...
Страница 4: ...vi...