Interrupt Programming Guidelines - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

Program instructions
7.10 Interrupt
7.10.3

Interrupt programming guidelines

Interrupt routine execution
An interrupt routine executes in response to an associated internal or external event. Once
the last instruction of an interrupt routine has executed, control returns to the point in the
scan cycle at the point of the interruption. You can exit the routine by executing a conditional
return from interrupt instruction (CRETI).
Interrupt processing provides quick reaction to special internal or external events. Optimize
your interrupt routines to perform a specific task, and then return control to the scan cycle.
Note
• You cannot use the disable interrupt (DISI), enable interrupt (ENI), high-speed counter
definition (HDEF), and end (END) instructions in an interrupt routine.
• Keep interrupt routine program logic short and to the point, so execution is quick and
other processes are not deferred for long periods of time. If this is not done, unexpected
conditions can cause abnormal operation of equipment controlled by the main program.
System support for interrupts
Because interrupts can affect contact, coil, and accumulator logic, the system saves and
reloads the logic stack, accumulator registers, and the special memory bits (SM) that
indicate the status of accumulator and instruction operations. This avoids disruption to the
main user program caused by branching to and from an interrupt routine.
Calling subroutines from interrupt routines
You can call four nesting levels of subroutines from an interrupt routine. The accumulators
and the logic stack are shared between an interrupt routine and the four nesting levels of
subroutines called from the interrupt routine
Sharing data between the main program and the interrupt routines
You can share data between the main program and one or more interrupt routines. Because
it is not possible to predict when the CPU might generate an interrupt, it is desirable to limit
the number of variables that are used by both the interrupt routine and elsewhere in the
program. Problems with the consistency of shared data can result due to the actions of
interrupt routines when the execution of instructions in your main program is interrupted by
interrupt events. Use the interrupt block "variable table" (block call interface table) to ensure
that your interrupt routine uses only the temporary memory and does not overwrite data used
somewhere else in your program.
326
System Manual, V2.3, 07/2017, A5E03822230-AF
S7-200 SMART

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-200 smart

Table of Contents