09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Interrupts <strong>Basic</strong> <strong>Characteristics</strong> <strong>RAPID</strong><br />

9.2 Trap routines<br />

Example: IDelete sig1int;<br />

Trap routines provide a means of dealing with interrupts. A trap routine can be connected<br />

to a particular interrupt using the CONNECT instruction. When an interrupt<br />

occurs, control is immediately transferred to the associated trap routine (if any). If an<br />

interrupt occurs, that does not have any connected trap routine, this is treated as a fatal<br />

error, i.e. causes immediate termination of program execution.<br />

Example: VAR intnum empty;<br />

VAR intnum full;<br />

.PROC main()<br />

CONNECT empty WITH etrap; connect trap routines<br />

CONNECT full WITH ftrap;<br />

ISignalDI di1, high, empty; define feeder interrupts<br />

ISignalDI di3, high, full;<br />

.<br />

IDelete empty;<br />

IDelete full;<br />

ENDPROC<br />

TRAP etrap responds to "feeder<br />

open_valve; empty" interrupt<br />

RETURN;<br />

ENDTRAP<br />

TRAP ftrap responds to "feeder full"<br />

close_valve; interrupt<br />

RETURN;<br />

ENDTRAP<br />

Several interrupts may be connected to the same trap routine. The system variable<br />

INTNO contains the interrupt number and can be used by a trap routine to identify an<br />

interrupt. After the necessary action has been taken, a trap routine can be terminated<br />

using the RETURN instruction or when the end (ENDTRAP or ERROR) of the trap<br />

routine is reached. Execution continues from the place where the interrupt occurred.<br />

5-36 <strong>RAPID</strong> Reference Manual

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!