Technical data
Appendix
27.2 Memory Areas of S7 CPUs
Programming with STEP 7
Manual, 05/2010, A5E02789666-01 581
!
Caution
When using temporary variables, remember that they are only valid within the relevant block or are
only available as previous local data for other blocks called in this block. In particular, there is no
guarantee that if you close and then re-open the block, the temporary variables will have the same
values they had when the previous block call was completed. Temporary variables are by definition
undetermined when a block is called and must be re-initialized again when they are used for the first
time in the block.
All the temporary variables (TEMP) of an OB and its associated blocks are saved in the L stack. If you
use too many nesting levels when executing your blocks, the L stack can overflow.
S7 CPUs change to STOP mode if the permitted L stack size for a program is exceeded.
Test the L stack (the temporary variables) in your program.
The local data requirements of synchronous error OBs must be taken into consideration.
Assigning Local Data to Priority Classes
Not every priority class requires the same amount of memory in the local data stack. By assigning
parameters in STEP 7, you can set different sized local data areas for the individual priority classes
for S7-400 CPUs and for the CPU 318. Any priority classes you do not required can be deselected.
With S7-400 CPUs and the CPU 318 the memory area for other priority classes is then increased.
Deactivated OBs are ignored during program execution and save cycle time.
With the other S7-300 CPUs every priority class is assigned a fixed amount of local data (256
bytes) that cannot be changed.
27.2.3.4 Interrupt Stack
If program execution is interrupted by a higher priority OB, the operating system saves the current
contents of the accumulators and address registers, and the number and size of the open data
blocks in the interrupt stack.
Once the new OB has been executed, the operating system loads the information from the I stack
and resumes execution of the interrupted block at the point at which the interrupt occurred.
When the CPU is in STOP mode, you can display the I stack on a programming device using STEP
7. This allows you to find out why the CPU changed to STOP mode.