×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 24411828, Entry date: 06/02/2015
(2)
Rate

How do you clear the message "Maximum length of code area reached (max. 64 Kbytes)"?

  • Entry
  • Associated product(s)
During compilation of the S7 program, the error message "Maximum length of code area reached (max. 64 Kbytes)" may occur.
Entry ID 771569 explains the possible causes of this error message. This entry describes the scenario where a configured SFC type is the cause for the 64 Kbyte limit being exceeded. The user has configured too many actions during step-by-step processing and too many conditions during transitions.
   

Fig. 01
  
However, this error message does not indicate which block (SFC type, for example) has caused the error. The instructions show how to conduct error diagnostics.

1. Repeat of the compile procedure with the "Generate SCL source" option

  • In the CFC editor, open the "Compile Program" dialog via the menu command "Chart > Compile > Charts as program...".
  • Ensure that the "Generate SCL source" option is checked and that "Entire Program" is selected under "Scope". Repeat the compilation process by clicking "OK".
     



    Fig. 02

Note
In older versions of PCS 7, the "Generate SCL source" option is not available in the Compile dialog box. In these cases, the SCL source is created by default.

2. Opening and compiling the generated SCL source
  • Switch to Component view in the SIMATIC Manager. In the navigation window in Component view, select the "Sources" folder for the relevant S7 program. The SCL source "@SCLFileFromCFC_SFC_1" is present in the working area.
     

    Fig. 03
     
  • Open this SCL source by double-clicking it or via "Open Object" in the pop-up menu.
  • Compile this source using the "File > Compile" menu command. "Overwrite Blocks" windows may appear. Click "All" to acknowledge them.
  • Wait until the compilation process has ended.
     
Note
During this compilation process, detailed information appears in the SCL editor's error window.

3. Evaluating a detailed compilation log
The name of the SFC type which causes the 64 Kbyte limit to be exceeded is determined in this step. It determines whether this is caused by there being too many actions during the step-by-step processing or too many instructions in the transition conditions.
   

Searching for errors in the compilation log
Switch to the "Errors" window in the SCL editor and scroll to the start of the compilation log. Now read through the compilation log from top to bottom, looking for error messages.

Note
Error entries commence with the string "E:" Warnings commence with the string "W:".

If there are no other errors contained in the program, the first error entry should be the error message which is described above.
The block (block number), during the compilation of which the error occurred, is indicated immediately above the error message. Take a note of this block number.
  

Fig. 04
 
Searching for the definition of the faulty block in the SCL source
Now switch to the SCL editor's program window and position the cursor at the start of the SCL source. Open the dialog "Find/Replace". Go to the "Find what" input field and enter the name of the block which was shown directly above the error message in the error log. Click the "Find" button to execute the search process. The cursor then jumps to an area of the source containing the definition of the block. In the event that this block is part of an SFC type, the symbolic name of the SFC type appears in the comment. Make a note of this name.
Note
If you double-click the block number, located above the error message, in the SCL editor's error window, the cursor jumps straight to the corresponding block in the program window. This saves you having to search through the program window.
 

Fig. 05
 
Searching for use of the defective block in the SCL source
Repeat the search with the same block number until the cursor jumps to the section of the program where this function is used. Above this line there is a comment line indicating whether the block is responsible for processing actions or transitions.
 

Fig. 06
  
Note
The comments in the SCL source appear in German, irrespective of the language setting in the SIMATIC Manager. "Aufruf AktionsFC ..." means processing actions whereas "Aufruf TransitionsFC ..." means processing transitions (alternatively, by analyzing the defective block's function body you can ascertain whether actions or transitions are being processed).

Scroll up through the SCL source slowly until you get to the start of the function block which is making the call. Make a note of the number of the block which is making the call.
 

Fig. 07
 
Note
You can also use the "Find and Replace" function to jump to the start of the function block. In order to do this, search for the "FUNCTION" string using the "From cursor up" option. The cursor then jumps to the start of a function block.

4. Checking the block number
In the Component view in the SIMATIC Manager you switch to the block folder . In the "Details" view, the first eight characters of the names of the SFC types appear in the "Name (Header)" column in addition to the block number.
  

Fig. 08
  
The block number was allocated during the configuration of the SFC type.
  

Fig. 09
 
Estimating the scope of the requisite code reduction
Depending on what is responsible for the 64 Kbyte limit being exceeded, the number of instructions must be reduced during step-by-step or transition processing. In order to assess the extent to which the number of instructions in the step sequence have to be reduced, you can halve the scope of the step sequence and then perform the compilation. This involves deleting about half of the steps and transitions. It is imperative to create a backup of the relevant block or of the entire project beforehand.
Should a message appear during the repeated compilation to indicate that the 64 Kbyte limit is still being exceeded, repeat the procedure. If compilation is successfully completed, this indicates that the 64 Kbyte limit is no longer being exceeded. You can then refer to the block folder in the SIMATIC Manager to determine the size of the blocks which are involved in the SFC type. Further information about this is available in Entry ID 24411054. You can determine the requisite code reduction from the number of times the volume of code is halved and from the resulting block size.

Code-reduction measures
The actual problem is not solved by "simply" deleting steps and transitions - Entry 24412494 contains possible remedies.

Note
The S7 program should be compiled before you finish creating an extensive SFC type. Perform interim compilations and determine the size of the blocks which are involved in the SFC type. This will enable you to detect early on whether the 64 Kbyte limit has been exceeded.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.