TMCM-351 TMCL Firmware V4.45 Manual (Rev. 1.06 / 2014-MAY-16)
46
www.trinamic.com
4.6.21
RSUB (return from subroutine)
Return from a subroutine to the command after the CSUB command.
This command is intended for use in standalone mode only.
Internal function:
the TMCL program counter is set to the last value of the stack. The command will be
ignored if the stack is empty.
Related command:
CSUB
Mnemonic:
RSUB
Binary representation:
INSTRUCTION NO.
TYPE
MOT/BANK
VALUE
24
don’t care
don’t care
don’t care
Binary format of RSUB:
Byte Index
0
1
2
3
4
5
6
7
Function
Target-
address
Instruction
Number
Type
Motor/
Bank
Operand
Byte3
Operand
Byte2
Operand
Byte1
Operand
Byte0
Value (hex)
$01
$18
$00
$00
$00
$00
$00
$00
Example:
Return form subroutine
Loop: MVP ABS, 0, 10000
CSUB SubW
//Save program counter and jump to label SubW
MVP ABS, 0, 0
JA Loop
SubW: WAIT POS, 0, 0
WAIT TICKS, 0, 50
RSUB
//Continue with the command following the CSUB command
Binary format of the CSUB SubW command assuming that the label SubW is at address 100:
Byte Index
0
1
2
3
4
5
6
7
Function
Target-
address
Instruction
Number
Type
Motor/
Bank
Operand
Byte3
Operand
Byte2
Operand
Byte1
Operand
Byte0
Value (hex)
$01
$17
$00
$00
$00
$00
$00
$64