ON TIMER msec label
or
ON EINT0|EINT1|EINT2 RISE|FALL|HIGH|LOW label
These statements will initialize interrupt service routines so that when
the interrupt occurs the code at label will be executed. Label
must have been pre-defined and can either be a SUB (without parameters) or code
beginning with a label: and ending in a RETURN. The interrupt response
time is approximately 3 usec. Other interrupts may make this time
longer.
TIMER interrupts will occur every msec milliseconds. msec may be a variable or constant, expressions are not allowed. The value for msec must be greater than 1. If TIMER interrupts are used, then only 4 hardware PWM channels are available.
EINT0 and EINT2 are 2 pins that will interrupt when the defined event occurs. RISE and FALL are the preferred method and will generate interrupts on rising or falling edges on those 2 pins. HIGH and LOW are supported, but if the pin remains in that state interrupts will be continuously generated.
EINT1 is connected to the RTS line of the PC, and is normally high, so it can be used by a program on the PC to interrupt the ARMmite, rather than having to reset the board. This pin is available on the wireless ARMmite, but if you intend to use it, make sure it is pulled high normally, otherwise when the board is reset it will go into the download C mode and will not run your BASIC program. EINT1 is also available on the ARMexpress modules (pin 21), and should also be kept normally high if used.
Each time the ON statement is executed the interrupt will be initialized, so it is possible to change routines within the program. Multiple interrupts can be used, but they are serviced in the order received, and each interrupt service routine will complete before the next one is handled (interrupts that occur while one is being serviced will be handled after the current interrupt is processed).
Interrupt routines should normally be short and simple. The state of the other user BASIC code will be restored after the interrupt, with the exception of string functions, which should NOT be done inside an interrupt. PRINT statements use strings, so other than a temporary debug to see if the interrupt occurs, they should not be inside an interrupt routine.
To disable the interrupt use the following #define
#defineVICIntEnClear *$FFFFF014
#define
TIMERoff VICIntEnClear = $20
#define
EINT0off VICIntEnClear = $4000
#define
EINT1off VICIntEnClear = $8000
#define EINT2off VICIntEnClear =
$10000
ON added in version 7.09
The LPC2106 based ARMexpress supports ONLY ON LOW, due to hardware limitations.
ON is a statement that is executed, so if multiple ON statements are in a program the last statement executed will be active command.
Cortex M3 and M0 do not support ON, but use INTERRUPT SUB