TMCL™ Firmware Manual - Trinamic
TMCL™ Firmware Manual - Trinamic
TMCL™ Firmware Manual - Trinamic
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
PD-109-57 V2 TMCL <strong>Firmware</strong> <strong>Manual</strong> (V1.00/2010-FEB-18) 61<br />
6.7.20 CSUB (call subroutine)<br />
This function calls a subroutine in the TMCL program memory. It is intended for stand-alone operation<br />
only.<br />
The host address and the reply are only used to take the instruction to the TMCL program memory<br />
while the TMCL program loads down. This command cannot be used in direct mode.<br />
Internal function: The actual TMCL program counter value is saved to an internal stack, afterwards<br />
overwritten with the passed value. The number of entries in the internal stack is limited to 8. This also<br />
limits nesting of subroutine calls to 8. The command will be ignored if there is no more stack space left.<br />
Related commands: RSUB, JA<br />
Mnemonic: CSUB <br />
Binary representation:<br />
INSTRUCTION NO. TYPE MOT/BANK VALUE<br />
23 (don't care) (don't care) <br />
Example: Call a subroutine<br />
Loop: MVP ABS, 0, 10000<br />
CSUB SubW //Save program counter and jump to label “SubW”<br />
MVP ABS, 0, 0<br />
JA Loop<br />
SubW: WAIT POS, 0, 0<br />
WAIT TICKS, 0, 50<br />
RSUB //Continue with the command following the CSUB command<br />
Binary format of the “CSUB SubW” command assuming that the label “SubW” is at address 100:<br />
Byte Index 0 1 2 3 4 5 6 7 8<br />
Function Target- Instruction Type Motor/ Operand Operand Operand Operand Checksum<br />
address Number<br />
Bank Byte3 Byte2 Byte1 Byte0<br />
Value (hex) $01 $17 $00 $00 $00 $00 $00 $64 $7c<br />
Copyright © 2010, TRINAMIC Motion Control GmbH & Co. KG