User manual

TMCM-1180 and PD86-1180 TMCL Firmware V4.42 Manual (Rev. 1.08 / 2012-NOV-20) 16
www.trinamic.com
For calculating purposes there is an accumulator (or accu or A register) and an X register. When executed in a
TMCL program (in standalone mode), all TMCL™ commands that read a value store the result in the
accumulator. The X register can be used as an additional memory when doing calculations. It can be loaded
from the accumulator.
When a command that reads a value is executed in direct mode the accumulator will not be affected. This
means that while a TMCL program is running on the module (standalone mode), a host can still send
commands like GAP, GGP or GIO to the module (e.g. to query the actual position of the motor) without
affecting the flow of the TMCL™ program running on the module.
5.4.6 Interrupt commands
Due to some customer requests, interrupt processing has been introduced in the TMCL™ firmware for ARM
based modules from revision 4.23 on. The TMCL-IDE supports the following commands from version 1.78 on.
Mnemonic
Command
number
Meaning
EI
25
Enable interrupt
DI
26
Disable interrupt
VECT
37
Set interrupt vector
RETI
38
Return from interrupt
5.4.6.1 Interrupt types:
There are many different interrupts in TMCL™, like timer interrupts, stop switch interrupts, position reached
interrupts, and input pin change interrupts. Each of these interrupts has its own interrupt vector. Each
interrupt vector is identified by its interrupt number. Please use the TMCL include file Interrupts.inc for
symbolic constants of the interrupt numbers.
5.4.6.2 Interrupt processing:
When an interrupt occurs and this interrupt is enabled and a valid interrupt vector has been defined for that
interrupt, the normal TMCL™ program flow will be interrupted and the interrupt handling routine will be
called. Before an interrupt handling routine gets called, the context of the normal program will be saved
automatically (i.e. accumulator register, X register, TMCL™ flags).
There is no interrupt nesting, i.e. all other interrupts are disabled while an interrupt handling routine is being
executed.
On return from an interrupt handling routine, the context of the normal program will automatically be
restored and execution of the normal program will be continued.
5.4.6.3 Interrupt vectors:
The following table shows all interrupt vectors that can be used.
Interrupt number
Interrupt type
0
Timer 0
1
Timer 1
2
Timer 2
3
Target position reached
15
stallGuard™
21
Deviation
27
Left stop switch
28
Right stop switch
39
Input change 0
40
Input change 1
255
Global interrupts