The area length error appears if references are made to addresses that do not exist in the STEP 7 program or when parameterizing the block call. The Online Help in STEP 7 gives two reasons for this:
- The value addressed by the access address is outside or not entirely inside the permissible address area (CPU-specific size).
- Due to an incorrect address calculation the addressed value is >65535. In the case of indirect addressing, an address value of greater than 65535 might occur through incorrect calculation. This value can no longer be entered correctly in the detail information of the event. Then for S7-300 a 0 is entered and displayed as access address and the calculated value module 65535 for S7-400.
Example 1 (Indirect Addressing)
You have programmed a function block or function with indirect addressing that reads data from a data block (DB20, for example), processes the data and then writes the data to a data block (DB23, for example). If now, when you call the block with the parameterization of the ANY pointer, the address areas of the data blocks called are exceeded, there is an "Area length error when reading" and / or an "Area length error when writing" if the address area of DB20 or DB23 in the example described above is less than the byte length of the ANY pointer parameterized.
Fig. 01 shows the example here of incorrect programming.
The ANY pointer "P#DB23.DBX0.0 BYTE 30" on the "PointerOutput" parameter of the called function block FB10 points to the addresses DB23.DBX0.0 to DB23.DBX29.7, because the length of the ANY pointer is 30 bytes (repeat factor). The repeat factor identifies the volume of the data type identified for transfer by the parameter type ANY. Here there is an "Area length error when writing", because the DB23 now only has a defined address area of 10 bytes (DB23.DBX0.0 to DB23.DBX9.7).
- Change the access address so that the addressed value lies entirely in the address area permitted in each case.
- Check the defined address area. According to the example above, either the length of the ANY pointer must be reduced by 20 bytes or the length of data block DB23 must be defined as 30 bytes (ARRAY[1..30]) or more.
Example 2 (FC100 "SWR_START")
With the two parameters "DB_A_B_NO_LEN" and "DB_B_A_NO_LEN" of the FC100 "SWR_START" from the software redundancy you enter the number of data bytes used in the data blocks ("DB_A_B_NO" and "DB_B_A_NO"). The number must be equal to or greater than 4 bytes. If, for example, you specify only 2 bytes, this might lead to the cycle time being exceeded by read and write errors. The CPU switches to STOP mode and you get the messages below displayed in the diagnostics buffer:
- Area length error when reading
- Area length error when writing
More information about parameterizing FC100 "SWR_START" is available in the manual "Software Redundancy for SIMATIC S7", under "Programmable Logic Controllers S7-300 Module Data" in Entry ID: 1137637.