Trinamic 11-0011 TMCM-171 BLDC Output For 3-phase BLDC Motors 11-0011 Data Sheet
Product codes
11-0011
TMCL Reference Manual
34
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
3.20 CSUB – Call Subroutine
Description: Calls a subroutine in the TMCL program memory. This command is intended for standalone operation
only and must not be used in direct mode.
Internal function: The actual TMCL program counter value is saved to an internal stack, then 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:
only and must not be used in direct mode.
Internal function: The actual TMCL program counter value is saved to an internal stack, then 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 NO.
TYPE
MOT/BANK
VALUE
23
(don't care)
(don't care)
<subroutine address>
Example: Call a 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
8
Function
Target-
address
address
Instruction
Number
Number
Type
Motor/
Bank
Bank
Operand
Byte3
Byte3
Operand
Byte2
Byte2
Operand
Byte1
Byte1
Operand
Byte0
Byte0
Checksum
Value (hex)
$01
$17
$00
$00
$00
$00
$00
$64
$7c
Note that the host address and the reply is only used to transfer this instruction to the TMCL program memory.
This command can not be used in direct mode.