User Manual
TMCM-1276 TMCL
™
Firmware Manual • Firmware Version V1.13 | Document Revision V1.01 • 2019-MAR-20
43 / 100
3.6.17 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 (don’t care) 0 (don’t care) <subroutine address>
Example
Call a subroutine:
Loop:
2
MVP ABS , 0, 10000
CSUB SubW // Save program counter and jump to label SubW
4
MVP ABS , 0, 0
CSUB SubW // Save program counter and jump to label SubW
6
JA Loop
8
SubW:
WAIT POS , 0, 0
10
WAIT TICKS , 0, 50
RSUB // Continue with the command following 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
©2019 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at www.trinamic.com