User manual
PD-1141 TMCL Firmware V1.19 Manual (Rev. 1.01 / 2012-JUL-27)  18 
www.trinamic.com   
3.4.2.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 
Stall (stallGuard2) 
21 
Deviation 
27 
Stop left 
28 
Stop right 
39 
IN_0 change 
40 
IN_1 change 
255 
Global interrupts 
3.4.2.6.4  Further Configuration of Interrupts 
Some interrupts need further configuration (e.g. the timer interval of a timer interrupt). This can be done 
using SGP commands with parameter  bank  3 (SGP <type>, 3, <value>).  Please  refer to  the SGP command 
(paragraph 3.6.9) for further information about that. 
3.4.2.6.5  Using Interrupts in TMCL 
For using an interrupt proceed as follows: 
-  Define an interrupt handling routine using the VECT command. 
-  If necessary, configure the interrupt using an SGP <type>, 3, <value> command. 
-  Enable the interrupt using an EI <interrupt> command. 
-  Globally enable interrupts using an EI 255 command. 
-  An interrupt handling routine must always end with a RETI command 
EXAMPLE FOR THE USE OF A TIMER INTERRUPT: 
 VECT 0, Timer0Irq //define the interrupt vector 
 SGP 0, 3, 1000 //configure the interrupt: set its period to 1000ms 
 EI 0 //enable this interrupt 
 EI 255 //globally switch on interrupt processing 
//Main program: toggles output 3, using a WAIT command for the delay 
Loop: 
 SIO 3, 2, 1 
 WAIT TICKS, 0, 50 
 SIO 3, 2, 0 
 WAIT TICKS, 0, 50 
 JA Loop 
//Here is the interrupt handling routine 
Timer0Irq: 
 GIO 0, 2 //check if OUT0 is high 
 JC NZ, Out0Off //jump if not 
 SIO 0, 2, 1 //switch OUT0 high 
 RETI //end of interrupt 
Out0Off: 
 SIO 0, 2, 0 //switch OUT0 low 
 RETI //end of interrupt 










