![Trinamic TMCM-351 Firmware Manual Download Page 18](http://html1.mh-extra.com/html/trinamic/tmcm-351/tmcm-351_firmware-manual_1163054018.webp)
TMCM-351 TMCL Firmware V4.45 Manual (Rev. 1.06 / 2014-MAY-16)
18
www.trinamic.com
4.4.2.7.5
Using Interrupts in TMCL
To use an interrupt the following things have to be done:
-
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
The following example shows 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
In the example above, the interrupt numbers are used directly. To make the program better readable use the
provided include file
Interrupts.inc.
This file defines symbolic constants for all interrupt numbers which can
be used in all interrupt commands. The beginning of the program above then looks like the following:
#include Interrupts.inc
VECT TI_TIMER0, Timer0Irq
SGP TI_TIMER0, 3, 1000
EI TI_TIMER0
EI TI_GLOBAL
Please also take a look at the other example programs.
4.4.2.8
ASCII Commands
Mnemonic
Command number
Meaning
-
139
Enter ASCII mode
BIN
-
Quit ASCII mode and return to binary mode. This command can
only be used in ASCII mode.