Interrupts; Defining An Interrupt Service Routine - Omron SYSMAC CV500-BSC11 Operation Manual

Basic units
Table of Contents

Advertisement

Interrupts

6-1

Interrupts

Interrupt Processing
Interrupt Type
TIME$
ALARM
TIMER
KEY(key-number)
COM
PC
FINS
SIGNAL signal-number
ERROR

6-1-1 Defining an Interrupt Service Routine

92
An interrupt is one means by which a device connected to the BASIC Unit can
inform the program that some event has occurred and that some action on the
part of the program is required immediately. For example, when a character is
received by a communications port, the program must stop whatever it is doing
and read the character as soon as possible so that the input buffer does not over-
flow. When an interrupt occurs, the BASIC Unit may stop executing the current
task and run an interrupt service routine instead. When the service routine is fin-
ished, control is returned to the task that was executing before the interrupt.
Interrupts can also be used to restart a task which has been stopped by the
PAUSE statement.
Main program
Interrupt occurs
The BASIC Unit supports several different interrupts which indicate various con-
ditions. The table below lists the interrupt types and related BASIC instructions.
Meaning
Time
Elapsed time
Time interval
Numeric key pressed
Input from communication port
Interrupt from CPU Unit
Interrupt from network
Signal received from another task
Error occurred
Before interrupts of a certain type can be processed, the program must define an
interrupt service routine to be called when that type of interrupt occurs. The ON
interrupt-type GOSUB { line-number | label } instruction is used for this purpose.
The line-number or label indicates the start of the service routine. Interrupt ser-
vice routines must end with a RETURN statement.
Interrupt service routine
BASIC Instructions
ON TIME$ GOSUB
TIME$ ON/OFF/STOP
ON ALARM GOSUB
ALARM ON/OFF/STOP
ON TIMER GOSUB
TIMER ON/OFF/STOP
ON KEY GOSUB
KEY ON/OFF/STOP
ON COM GOSUB
COM ON/OFF/STOP
ON PC GOSUB
PC ON/OFF/STOP
ON FINS GOSUB
FINS ON/OFF/STOP
ON SIGNAL GOSUB SIGNAL ON/OFF/STOP
ON ERROR GOSUB
ERROR ON/OFF/STOP
Section 6-1

Advertisement

Table of Contents
loading

Table of Contents