Call Subroutine

Operands Data Types
n: Constant Constant

Memory Ranges ENO Errors Instruction Support for S7-200 CPUs SIMATIC/International Mnemonics
The Subroutine instruction or STL CALL instruction transfers control to the subroutine (n). You can use a Subroutine instruction with or without parameters.

Notes:* The maximum limit of input/ output parameters for each subroutine call is 16. If you attempt to download a program that exceeds this limit, an error is returned.
** If you have assigned a symbolic name to your subroutine, such as USR_NAME, this symbolic name appears in the Subroutine folder of the Instruction Tree.

Assignment of parameter values to local memory in the subroutine is as follows.

1. Parameter values are assigned to local memory in the order
specified by the CALL with parameters starting at L.0.

2. One to eight consecutive bit parameter values are assigned to a
single byte starting with Lx.0 and continuing to Lx.7.

3. Byte, word, and double word values are assigned to local
memory on byte boundaries (LBx, LWx, or LDx).

In the Subroutine CALL instruction with parameters, parameters must exactly match the variables defined in the local variable table of the subroutine. The parameters must be arranged in order with input parameters first, followed by input/output parameters, followed by output parameters.

STL Example:

CALL 10, I0.0, I1.0, VB20, VW20, VD30, VD40, Q2.0

//CALL 10, I0.0(in), I1.0(in), VB20(in), VW20(in), VD30(in), VD40(in/out), Q2.0(out)

On calling:

<I0.0>L0.0 <I1.0>L0.1 <VB20>LB1 <VW20>LW2 <VD30>LD4 <VD40>LD8

On returning:

<LD8>VD40 <LI2.0>Q2.0

Note: The tool tip for the subroutine name located in the instruction tree displays the name for each parameter.

Error Conditions that Set ENO for CALL with parameters = 0:

0008 (maximum subroutine nesting exceeded), SM4.3 (run-time)

See Also: