User Manual

PD-x-1670 TMCL
Firmware Manual Firmware Version V2.0 | Document Revision V1.0 2018-Oct-29
40 / 82
3.6.19 CSUB (Call Subroutine)
This function calls a subroutine in the TMCL program memory. It is intended for standalone operation only.
Internal function:
the actual TMCL program counter value is saved to an internal stack, afterwards
overwritten with the passed value. The number of entries in the internal stack is limited to 8. This also
limits nesting of subroutine calls to 8. The command will be ignored if there is no more stack space left.
Related commands: RSUB, JA.
Mnemonic: CSUB <label>
Binary Representation
Instruction Type Motor/Bank Value
23 0 (dont care) 0 (dont care) <subroutine address>
Example
Call a subroutine:
Loop :
2 MVP ABS , 0, 10000
CSUB SubW // Save program count er and jump to label SubW
4 MVP ABS , 0, 0
CSUB SubW // Save program count er and jump to label SubW
6 JA Loop
8 SubW :
WAIT POS , 0, 0
10 WAIT TICKS , 0 , 50
RSUB // Co ntinue with the comm and followin g the CSUB command
Binary form of CSUB SubW
(assuming SubW at address
100)
Field Value
Target address 01
h
Instruction number 17
h
Type 00
h
Motor/Bank 00
h
Value (Byte 3) 00
h
Value (Byte 2) 00
h
Value (Byte 1) 00
h
Value (Byte 0) 64
h
Checksum 7C
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at www.trinamic.com