5-15
S7-200 Programmable Controller, CPU 210
C79000-G7076-C235-01
Guidelines and Restrictions for Using the Interrupt Routine
Interrupt processing provides quick reaction to an I/O event. You should optimize the
interrupt routine to perform a specific task, and then return control to the main routine. By
keeping the interrupt routine short, 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.
The following restrictions apply to the use of the interrupt routine:
S
You must put the interrupt routine after the end of the main program.
S
You cannot use the Disable Interrupt (DISI), Enable Interrupt (ENI), or the End (MEND)
instructions in the interrupt routine.
S
You must terminate the interrupt routine by a Return from Interrupt instruction (RETI).
Contact and coil logic may be affected by interrupts. To avoid the disruption of the main
program segment (caused by branching to and from the interrupt routine), the operating
system of the CPU saves and reloads the logic stack and the special memory (SM) bits that
indicate the status of instruction operations.
Sharing Data Between the Main Program and the Interrupt Routine
You can share data between the main program and the interrupt routine. 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 the interrupt
routine when the execution of instructions in your main program is interrupted by an interrupt
event.
There are a number of programming techniques you can use to ensure that data is correctly
shared between your main program and interrupt routine. These techniques either restrict
the way access is made to shared memory locations, or make instruction sequences using
shared memory locations unable to be interrupted.
S
For a ladder program that is sharing a single variable: Use the Move (MOV_W)
instruction to access a shared variable. While many ladder instructions are composed of
interruptible sequences of STL instructions, the Move instruction in ladder is composed of
a single STL instruction whose execution cannot be affected by interrupt events.
S
For an STL or a ladder program that is sharing multiple variables: If the shared data is
composed of a number of related words, you can use the interrupt disable/enable
instructions (DISI and ENI) to control the execution of the interrupt routine. At the point in
your main program where operations on shared memory locations are to begin, disable
the interrupt. Once all actions affecting the shared locations are complete, re-enable the
interrupt. During the time that interrupts are disabled, the interrupt routine cannot execute
and therefore cannot access the shared memory locations; however, this approach can
cause interrupt events to be missed.
S
If the interrupt routine and the main program are sharing a bit in a byte, then the
remaining seven bits cannot be used for any purpose. For example: if
M1.0
is being used
for coordination between the interrupt routine and the main program, then
M1.1
through
M1.7
cannot be used for any purpose.
Instruction Set
Содержание Simatic S7-200 CPU 210
Страница 10: ...x S7 200 Programmable Controller CPU 210 C79000 G7076 C235 01 Contents ...
Страница 68: ...3 28 S7 200 Programmable Controller CPU 210 C79000 G7076 C235 01 Getting Started with a Sample Program ...
Страница 116: ...A 16 S7 200 Programmable Controller CPU 210 C79000 G7076 C235 01 CPU 210 Data Sheets ...
Страница 126: ...F 2 S7 200 Programmable Controller CPU 210 C79000 G7076 C235 01 CPU 210 Order Numbers ...
Страница 138: ...Index 12 S7 200 Programmable Controller CPU 210 C79000 G7076 C235 01 Index ...