Technical data

Checking Block Consistency and Time Stamps as a Block Property
15.8 Avoiding Errors when Calling Blocks
Programming with STEP 7
Manual, 05/2010, A5E02789666-01 331
15.8 Avoiding Errors when Calling Blocks
STEP 7 Overwrites Data in the DB Register
STEP 7 modifies the registers of the S7-300/S7-400 CPU when various instructions are executed.
The contents of the DB and DI registers are, for example, swapped when you call an FB. This
allows the instance DB of the called FB to be opened without losing the address of the previous
instance DB.
If you work with absolute addressing, errors can occur accessing data saved in the registers. In
some cases, the addresses in the register AR1 (address register 1) and in the DB register are
overwritten. This means that you could read or write to the wrong addresses.
!
Danger
Danger of damage to property and persons when:
1. Using CALL FC, CALL FB, CALL multiple instance
2. Accessing a DB using the complete absolute address (for example DB20.DBW10)
3. Accessing variables of a complex data type
It is possible that the contents of DB registers (DB and DI), address registers (AR1, AR2), and
accumulators (ACCU1, ACCU2) may be changed.
In addition, you cannot use the RLO bit of the status word as an additional (implicit) parameter when
you call an FB or FC.
When using the programming techniques mentioned above, you must make sure that you save and
restore the contents yourself; otherwise errors may occur.
Saving Correct Data
The contents of the DB register can cause critical situations if you access the absolute addresses
of data using the abbreviated format. If, for example, you assume that DB20 is open (and that its
number is saved in the DB register), you can specify DBX0.2 to access the data in bit 2 of byte 0 of
the DB whose address is entered in the DB register (in other words DB20). If, however, the DB
register contains a different DB number you access the wrong data.
You can avoid errors when accessing data of the DB register by using the following methods to
address data:
Use the symbolic address
Use the complete absolute address (for example DB20.DBX0.2)
If you use these addressing methods, STEP 7 automatically opens the correct DB. If you use the
AR1 register for indirect addressing, you must always load the correct address in AR1.