Skip to main content

Call Subroutine (Program)

Instruction Parameters

Supported PLC Series

XPnA/1RXPnBXPnEXPnFCP3A/B/P/U
CP4A~D/U
CPnECPnFBPPLC-S

Supported Data Registers

MXYKLFTCSZRQD@DConstant
PID--------------
n--------------

Supported Flags

FlagBitSupport
ErrorF11.0-
ZeroF11.1-
CarryF11.2-

Number of Steps

Steps
2

Operands

OperandDescription
PIDThe first operand.
Entries are only constants.
This is the external program ID.
nThe second operand.
Entries are only constants.
This is the subroutine ID.

The value range is 0 ~ 127.

Notice

Notice

Errors will occur when the following conditions are met:

  • The END instruction is located between the SBRT and RET instructions.
  • The nesting of the ECALL or ECALLP occurs more than 16 times.
  • The JMP/JMPP ~ JMP/JMPP block is located between the SBRT ~ RET block.
Instruction Behavior

The ECALL and ECALLP instructions behave as follows:

  • The ECALL or ECALLP instructions in a scan program calls the subroutine program of SBRT ~ RET block inside an external program.
    • The external program may be a scan or subroutine program.
  • When the execution condition is ON (1), the ECALL or ECALLP instruction calls the subroutine program, PID, with the assigned subroutine ID number, n.
  • When the subroutine is completed, the program continues execution after the ECALL or ECALLP instructions.
  • The ECALL and ECALLP instructions can be nested up to 16 times.
  • The ECALL and ECALLP instructions can be used multiple times in the same program.
  • When SBRT is duplicated in the external program file, a compile error occurs.
Block vs. Program

This section covers information about the ECALL and ECALLP instructions, where a subroutine program is called.
For more information about using a subroutine block, refer to the SBRT, RET, and CALL or CALLP instructions.

Examples