FX Series Programmable Controlers Applied Instructions 5
5-7
5.1.2 CALL (FNC 01)
Points to note:
a) Many CALL statements can reference a single subroutine.
b) Each subroutine must have a unique pointer number. Subroutine pointers can be selected
from the range P0 to P62. Subroutine pointers and the pointers used for CJ (FNC 00)
instructions are NOT allowed to coincide.
c) Subroutines are not normally processed as they occur after an FEND instruction. When
they are called, care should be taken not to overrun the watchdog timer setting. For more
information on watchdog timers please see page 5-12.
d) Subroutines can be nested for 5 levels including
the initial CALL instruction. As an example the
program shown opposite shows a 2 level nest.
When X1 is activated the program calls subroutine
P11. Within this subroutine is a CALL to a second
subroutine P12. When both subroutines P11 and
P12 are active simultaneously, they are said to be
nested. Once subroutine P12 reaches its SRET
instruction it returns the program control to the
program step immediately following its original
CALL (see
À). P11 then completes its operation,
and once its SRET instruction is processed the
program returns once again to the step following
the CALL P11 statement (see
Á).
Mnemonic Function
Operands
Program steps
D
CALL
FNC 01
(
Call sub-
routine
)
Executes the
subroutine
program starting
at the identified
pointer position
Valid pointers from the range 0 to 62
Nest levels: 5 including the initial CALL
CALL, CALLP:
3step
Subroutine pointer
P
PP:1steps
FX
1S
FX1N FX2N
FX2NC
X0
P 10CALL
FEND
SRET
P10
[ D ]
Subroutine D10
Operation:
When the CALL instruction is active it forces the
program to run the subroutine associated with the
called pointer (area identified as subroutine P10). A
CALL instruction must be used in conjunction with
FEND (FNC 06) and SRET (FNC 02) instructions. The
program jumps to the subroutine pointer (located after
an FEND instruction) and processes the contents until
an SRET instruction is encountered. This forces the
program flow back to the line of ladder logic
immediately following the original CALL instruction.
PULSE-P
16 BIT OPERATION
32 BIT OPERATION
P 11CALL
FEND
SRET
P11
P 12CALL
SRET
P12
1
2