Call Subroutine (Program)
Instruction Parameters
Supported PLC Series
| XPnA/1R | XPnB | XPnE | XPnF | CP3A/B/P/U CP4A~D/U | CPnE | CPnF | BP | PLC-S |
|---|---|---|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Supported Data Registers
| M | X | Y | K | L | F | T | C | S | Z | R | Q | D | @D | Constant | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PID | - | - | - | - | - | - | - | - | - | - | - | - | - | - | ✓ |
| n | - | - | - | - | - | - | - | - | - | - | - | - | - | - | ✓ |
Supported Flags
| Flag | Bit | Support |
|---|---|---|
| Error | F11.0 | - |
| Zero | F11.1 | - |
| Carry | F11.2 | - |
Number of Steps
| Steps |
|---|
| 2 |
Operands
| Operand | Description |
|---|---|
| PID | The first operand. Entries are only constants. This is the external program ID. |
| n | The second operand. Entries are only constants. This is the subroutine ID. The value range is 0 ~ 127. |
Notice
Notice
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.