System Software for S7-300/400 System and Standard Functions Volume 1/2
118 Reference Manual, 05/2010, A5E02789976-01
3.11 Writing a Data Block in Load Memory with SFC 84 "WRIT_DBL"
Description
With the SFC 84 "WRIT_DBL" (write data block in load memory) you can transfer the contents of a DB or a DB area from the work memory to a DB or a DB area in the Micro Memory Card. The source DB must be process relevant; that is, it must not have been created with the attribute UNLINKED. However, it may also be generated with SFC 22 "CREAT_DB".
To ensure consistency, you must not change the source area while the SFC 84 is being processed (i.e. as long as the BUSY parameter has the value TRUE).
The following restrictions apply to the parameters SRCBLK (source block) and DSTBLK (destination block):
• For an ANY pointer of the type BOOLEAN the length must be divisible by 8. • For an ANY pointer of the type STRING the length must be equal to 1.
If required, you can determine the length of the target DB with SFC 24 "TEST_DB".
SFC 84 does not change the checksum of the user program if you describe a DB that was generated via SFC. However, when writing a loaded DB the first entry in this DB changes the checksum of the user program.
Note
SFC 84 is not suitable for frequent (or cyclical) writing of variables to the load memory writing. This is because the technology of Micro Memory Cards means that only a certain number of write accesses can be made to a Micro Memory Card. For more information, see the reference manual "SIMATIC
S7-300 Programmable Controller CPU Data: CPU 31xC and CPU 31x".
Operating principle
The SFC 84 "WRIT_DBL" operates asynchronously, that is, processing covers multiple SFC calls. Start the job by calling SFC 84 with REQ = 1.
The job status is displayed via the output parameters RET_VAL and BUSY.
Refer also to Meaning of REQ, RET_VAL and BUSY with Asynchronously Operating SFCs
Parameters Declaration Data type Memory area Description
REQ INPUT BOOL I, Q, M, D, L REQ = 1: Write request
SRCBLK INPUT ANY D Pointer to DB in the work memory from which is to be read
RET_VAL OUTPUT INT I, Q, M, D, L Error information
BUSY OUTPUT BOOL I, Q, M, D, L BUSY = 1: The write process is not yet terminated.
DSTBLK OUTPUT ANY D Pointer to the data block in the load memory that is to be written to
3.11 Writing a Data Block in Load Memory with SFC 84 "WRIT_DBL" Error Information Error code (W#16#...): Description 0000 no error
0081 The target range is larger than the source range.
The source area is written completely to the target area. The remaining bytes of the target area are not changed.
7000 First call with REQ=0: no data transfer active; BUSY has the value 0. 7001 First call with REQ=1: no data transfer active; BUSY has the value 1.
7002 Intermediate call (REQ irrelevant): data transfer already active; BUSY has the value 1. 8081 The source range is larger than the target range.
The target range is fully written. The remaining bytes of the source area are ignored.
8092 Incorrect operating mode: While the SFC 84 was active, the CPU went into STOP mode. This error code is supplied at the next transition to RUN. Call SFC 84 again. 8093 No data block or a data block that is not in the work memory is indicated for the
parameter SRCBLK.
80B1 No data block is indicated for the parameter DSTBLK, or the data block indicated there is not an object in the load memory (e.g. a DB generated by SFC 22).
80B4 A DB with F attribute must not be changed
80C0 The target is currently being processed by another SFC or communication operation. Example: You upload a DB from the CPU to the programming device (PG). You want to change the contents of this DB with SFC 84.
80C3 The maximum number of simultaneously active SFC 84 is currently reached. 8xyy General error codes, see Evaluating Errors with the Output Parameter RET_VAL
3.12 Creating a Data Block with SFC 85 "CREA_DB"
System Software for S7-300/400 System and Standard Functions Volume 1/2
120 Reference Manual, 05/2010, A5E02789976-01
3.12 Creating a Data Block with SFC 85 "CREA_DB"
Description
With SFC 85 "CREA_DB" (create data block) you create a data block with no default values in the user program. Instead, the DB contains random data. The SFC creates a data block with a number from a specified area and with a default size. The SFC assigns the smallest possible number from this area to the DB. To create a DB with a specific number, enter the same number for the upper and lower limits of the default area. You cannot issue the numbers from the DBs already continued in the user program. The length of the DB must be specified with an even number.
Depending on the selection made for the ATTRIB parameter, the DB created has the property RETAIN or NON_RETAIN:
• RETAIN means that the DB is created in the retentive part of the work memory. This means the current values of the DB are retained after each power OFF/power ON transition and every restart (warm restart).
• NON_RETAIN means that the DB is created in the non-retentive part of the work memory. . This means the current values of the DB are undefined after each power OFF/power ON transition and every restart (warm restart).
If no distinction is made between retentive and non-retentive work memory, the ATTRIB parameter is ignored. This means the values of the DB are retained after each power OFF/power ON transition and every restart (warm restart).
3.12 Creating a Data Block with SFC 85 "CREA_DB"
Interruptability
SFC 85 "CREA_DB" can be interrupted by higher-priority OBs. If SFC 85 "CREA_DB" is again called in a higher-priority OB, this call is rejected with the error code W#16#8091.
Parameter Declaration Data Type Memory area
Description
LOW_LIMIT INPUT WORD I, Q, M, D, L constant
The lower limit value is the lowest number in the range of numbers that you can assign to your data block.
UP_LIMIT INPUT WORD I, Q, M, D, L constant
The upper limit value is the highest number in the range of numbers that you can assign to your data block.
COUNT INPUT WORD I, Q, M, D, L constant
The count value indicates the number of data bytes that you want to reserve for your data block. You must specify an even number of bytes (maximum 65534). ATTRIB INPUT BYTE I, Q, M, D, L
constant
DB attributes:
• B#16#00: RETAIN • B#16#04: NON_RETAIN RET_VAL OUTPUT INT I, Q, M, D, L If an error occurs during processing, the
function, the return value contains an error code.
DB_NUMBER OUTPUT WORD I, Q, M, D, L The data block number is the number of the created data block. In case of an error, (bit 15 for RET_VAL was set) the value of 0 is entered in DB_NUMBER.
3.12 Creating a Data Block with SFC 85 "CREA_DB"
System Software for S7-300/400 System and Standard Functions Volume 1/2
122 Reference Manual, 05/2010, A5E02789976-01
Error Information
Error Code (W#16#...)
Description
0000 No error
8091 You have called SFC 85 nested.
8092 The "Create a DB" function is currently unavailable because • The "Compress User Memory" function is currently active
• The WinAC software CPU has detected an error in the OS of the computer on which WinAC is installed.
8094 Invalid value in ATTRIB 80A1 Error in number for DB:
• The number is 0
• The number exceeds the CPU-specific DB numbers • Lower limit > upper limit
80A2 Error in length of DB: • The length is 0
• The length was specified with an uneven number • The length is greater than the CPU allows 80B1 There is no DB number free.
80B2 There is not enough free memory available.
80B3 There is not enough contiguously memory available (compress it!)