Specifications

SIMATIC Instructions
9-168
S7-200 Programmable Controller System Manual
C79000-G7076-C233-01
Calling Subroutine From Interrupt Routines
You can call one nesting level of subroutines from an interrupt routine. The
accumulators and the logic stack are shared between an interrupt routine and a
subroutine that is called.
Sharing Data Between the Main Program and Interrupt Routines
You can share data between the main program and one or more interrupt routines.
For example, a part of your main program may provide data to be used by an
interrupt routine, or vice versa. If your program is sharing data, you must also
consider the effect of the asynchronous nature of interrupt events, which can occur
at any point during the execution of your main 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.
There are a number of programming techniques you can use to ensure that data is
correctly shared between your main program and interrupt routines. These
techniques either restrict the way access is made to shared memory locations, or
prevent interruption of instruction sequences using shared memory locations.
For an STL program that is sharing a single variable: If the shared data is a
single byte, word, or double-word variable and your program is written in STL,
then correct shared access can be ensured by storing the intermediate values
from operations on shared data only in non-shared memory locations or
accumulators.
For a LAD program that is sharing a single variable: If the shared data is a
single byte, word, or double-word variable and your program is written in LAD,
then correct shared access can be ensured by establishing the convention that
access to shared memory locations be made using only Move instructions
(MOVB, MOVW, MOVD, MOVR). While many LAD instructions are composed
of interruptible sequences of STL instructions, these Move instructions are
composed of a single STL instruction whose execution cannot be affected by
interrupt events.
For an STL or LAD program that is sharing multiple variables: If the shared data
is composed of a number of related bytes, words, or double-words, then the
interrupt disable/enable instructions (DISI and ENI) can be used to control
interrupt routine execution. At the point in your main program where operations
on shared memory locations are to begin, disable the interrupts. Once all
actions affecting the shared locations are complete, re-enable the interrupts.
During the time that interrupts are disabled, interrupt routines cannot be
executed and therefore cannot access shared memory locations; however, this
approach can result in delayed response to interrupt events.