Command INT
 
Description If an interrupt occurs for the specified buffer, it will run a function.
An interrupt will occur when a buffer’s style parameters allow activity within the buffer and the appropriate type of interrupt is set.
Serial interfaces can trigger on a byte received, a byte transmitted and a
semi-colon (command separator) received. I/O can trigger on input change.
Use HIDE(Name); to disable an interrupt.

Interrupts are available for counters and timers CNTMILLI...TIMER0. See relative section.
 
Syntax/Parameters INT(Name,Buffer,Function,Priority);
   
    Name Of Interrupt

    Buffer to Interrupt on
       
  > RS2RXC = RS232 Receive Character
          > RS4RXC = RS485 Receive Character
          > AS1RXC = Async1 Receive Character
          > AS2RXC = Async2 Receive Character
          > SPIRXC = SPI Recieve Character
       
  > I2CRXC = I2C Receive Character
          > USBRXC = USB Recieve Character
       
  > DBGRXC = Debug Receive Character

          > TOUCHI = Touch Inactivity Timeout

          > ENC = Rotary Encoder 1
          >
ENC1 = Rotary Encoder 1
          > ENC2 = Rotary Encoder 2

          > K0 = IO Port K0 or K00
          > ....
          > K30 = IO Port K30

          > TIMER0 = Timer0
          > ....
          >
TIMER19 = Timer19

          > CNTMILLI =  CNTMILLI timer
          > CNTSECS = CNTSECS timer
          > CNTMINS
= CNTMINS timer
          > CNTHOURS = CNTHOURS timer
          > CNTDAYS = CNTDAYS timer

    Function to call when Buffer read

    Priority - Optional
 
Options Interrupts can be assigned a priority for faster processing by providing an optional parameter in the INT() command:
INT(name,source,func,priority);
* The default priority will be 0 which will run INT()'s as implemented until now (ie more like pending tasks).
* A value greater than 0 will process the INT() as soon as the interrupt condition has occurred. Interrupts with larger values will have
   a higher priority and can interrupt those with a lower value.
* The range of values are 0 to 15.
* Only one interrupt is permitted per priority level.
* As these interrupts are being processed as true interrupts some commands are not supported. The non-supported commands will
   return an error. These are:
   SHOW(page); // though ;; and SHOW(THIS_PAGE); are supported, see below.
   EXIT();
   FPROG;
   FEND;
* Page refreshing of the currently viewed page is allowed with ";;" or SHOW(THIS_PAGE); BUT changing to another page is not allowed
   from an INT() with priority greater than 0 as this could cause undesired effects. Care should be taken with refreshing a page from an
   INT() as this will lock out other interrupts during this time.
* Interrupt routines should be kept as short as possible to avoid locking out other interrupts and the main processing.

NOTE: The Buffer must be read to clear the interrupt otherwise the Function will keep getting called!

HIDE/SHOW(INT) - v49.03
Pending interrupts are now processed when an interrupt entity is unhidden.

Priority Interrupts - Modified Priority Scheme - v49.37
Modified functionality to always process higher priority interrupts pending rather than process multiple interrupts pending at current level.

Losing Serial Interrupts with "proc" - v49.37
A new INT() processing scheme has been written which has abandoned a "counter" method and instead checks to see if there are any further "packets" waiting to be processed when the INT() command is run.
The old scheme made use of a counter which was incremented in the "hardware" interrupt handler when a packet was received and then decremented when a LOAD(buf,port); was performed from the INT() function. It had been found that the counter can get out of sync with the packets being received and hence packets are left in the receive buffer when the counter has a value of zero.
The new method, sets a task flag in the "hardware" interrupt handler to say a packet has been received. The INT() function then reads the packet when the LOAD(buf,port); command is used and then checks to see if there is another complete packet in the receive buffer. If there is, then the INT() function is called again, and so on, until there are no more complete packets and then the INT() is exited and normal processing resumes.

Nesting of priority INT()s - v49.44
New functionality has been added to support nesting of priority INT()s, ie a priority interrupt can be interrupted by another priority
interrupt with a higher priority (this is now the default behaviour).

A system setup variable has been added to disable this functionality.
SETUP(SYSTEM){ intNest = y | n; } // default = y;

For 'y', priority INT()s can be interrupted by higher priority INT()s
For 'n', priority INT()s run to completion, then the highest pending priority INT() is processed next.

Real Time (Priority) Interrupts - v 49.44
This issue has been resolved. A problem was found with the operating systems' nested interrupt handler. New functionality has been
implemented and tested.
Nesting of priority INT()s has also been added - see TFT Improvement
 
Example PAGE( PageName, PageStyle) 
 {
  INT( SerRxInt, RS2RXC, SerRxEvent );
 }
 FUNC( SerRxEvent )
 {
 LOAD( Var, RS2 ); // Must read RS2 to clear interrupt
 LOAD( RS4, Var);  //send out of RS485 interface.
 TEXT ( RecvTxt, Var);; //show received ASCII data on screen and Refresh
 }
SHOW/HIDE(INT) Example
INT( intRs2, RS2RXC, fncRs2Rx ); // Create RS2 receive interrupt
HIDE( intRs2 ); // Hide the interrupt
SHOW( intRs2 ); // Show (Enable) interrupt and process pending interrupts
//If you don't want to process any pending interrupts when you show the interrupt then RESET the interrupt first
INT( intTmr0, TIMER0, fncTmr0 ); // Create RS2 receive interrupt
HIDE( intTmr0 ); // Hide the interrupt
RESET( intTmr0 ); // Clear any pending interrupts
SHOW( intTmr0 ); // Show (Enable) interrupt for future interrupts
 
Update Information

 Version

 Title

Date  

 Details

00.01.00

 Empty Inline Functions [] now supported

13 Feb 15 

Show

---

49.48

 External I/O Interrupts Being Missed

21 Nov 13 

Show

* Fixed problem where external interrupts (K00-K30) faster than interrupt function were being missed.
* INT() priority can now be specified for extern key interrupts.

49.48

 System Timer Accuracy

21 Nov 13 

Show

* Fixed accuracy of 200us system tick timer - used for incrementing counters CNTRUN, CNTMILLI, ... CNTDAYS, TIMER0-TIMER19, and decrementing WAIT().
* Wrong divider value was being used. Needed to be divider value minus one.
* This resulted in a tick value of 200.174us rather than 200us.
* Assuming a perfect crystal frequency giving a 92,000,000Hz clock then there would be a +0.87ms error for every second.

49.47

 Extra INT()'s Problem when Reading into Array

31 Oct 13 

Show

* Problem fixed with LOAD( varArr, port ); when using procDel = y and encode = sd, d8m, d8l, d16m, d16l, d32m, d32l, sh, h8m, h8l, h16m, h16l, h32m, h32l.
* An additional INT() was produced due to the terminator characters not being skipped correctly, no data was loaded on the second INT() ie varArr was not modified.
* The termination characters with procDel = y are now correctly skipped and only one INT() is performed per packet.

49.44

 Nesting of priority INT()s

09 Oct 13 

Show

New functionality has been added to support nesting of priority INT()s, ie a priority interrupt can be interrupted by another priority interrupt with a higher priority (this is now the default behaviour).

A system setup variable has been added to disable this functionality.
SETUP(SYSTEM){ intNest = y | n; } // default = y;

For 'y', priority INT()s can be interrupted by higher priority INT()s
For 'n', priority INT()s run to completion, then the highest pending priority INT() is processed next.

49.44

 Real Time (Priority) Interrupts

09 Oct 13 

Show

This issue has been resolved. A problem was found with the operating systems' nested interrupt handler. New functionality has been implemented and tested.
Nesting of priority INT()s has also been added - see TFT Improvement

49.44

 External Keys Being Missed During Input Comms

05 Oct 13 

Show

New Key Scan algorithm implemented

49.43

 Add Single Key I/O Global Interrupt Capability

12 Sep 13 

Show

* The KEY interrupt can now be defined globally as well as in a page.

49.43

 KEYIO Interrupts Not Working

12 Sep 13 

Show

* Fixed problems with Key Interrupts operating incorrectly.

49.42

 Show/Hide of I/O Interrupts

06 Sep 13 

Show

* I/O interrupts are now handled the same as other interrupts therefore can now be enabled / disabled via the use of SHOW() / HIDE()

49.37

 Losing Serial Interrupts with ''proc''

10 Jun 13 

Show

A new INT() processing scheme has been written which has abandoned a "counter" method and instead checks to see if there are any further "packets" waiting to be processed when the INT() command is run.

The old scheme made use of a counter which was incremented in the "hardware" interrupt handler when a packet was received and then decremented when a LOAD(buf,port); was performed from the INT() function. It had been found that the counter can get out of sync with the packets being received and hence packets are left in the receive buffer when the counter has a value of zero.

The new method, sets a task flag in the "hardware" interrupt handler to say a packet has been received. The INT() function then reads the packet when the LOAD(buf,port); command is used and then checks to see if there is another complete packet in the receive buffer. If there is, then the INT() function is called again, and so on, until there are no more complete packets and then the INT() is exited and normal processing resumes.

49.37

 Priority Interrupts - Modified Priority Scheme

10 Jun 13 

Show

Modified functionality to always process higher priority interrupts pending rather than process multiple interrupts pending at current level.

49.34

 Priority Interrupts - Corrected multiple interrupt processing when more than one timer interrupt specified.

23 Feb 13 

Show

Priority Interrupts
* Corrected multiple interrupt processing when more than one timer interrupt specified.

49.32

 ''Real Time'' Interrupts - Interrupts can now be assigned a priority for faster processing.

14 Feb 13 

Show

* Interrupts can now be assigned a priority for faster processing by providing an optional parameter in the INT() command:
INT(name,source,func,priority);
* The default priority will be 0 which will run INT()'s as implemented until now (ie more like pending tasks).
* A value greater than 0 will process the INT() as soon as the interrupt condition has occurred. Interrupts with larger values will have a higher priority and can interrupt those with a lower value.
* The range of values are 0 to 15.
* Only one interrupt is permitted per priority level.
* As these interrupts are being processed as true interrupts some commands are not supported. The non-supported commands will return an error. These are:
SHOW(page); // though ;; and SHOW(THIS_PAGE); are supported, see below.
EXIT();
FPROG;
FEND;
* Page refreshing of the currently viewed page is allowed with ";;" or SHOW(THIS_PAGE); BUT changing to another page is not allowed from an INT() with priority greater than 0 as this could cause undesired effects. Care should be taken with refreshing a page from an INT() as this will lock out other interrupts during this time.
* Interrupt routines should be kept as short as possible to avoid locking out other interrupts and the main processing.

49.03

 HIDE / SHOW( INT ) - Pending interrupts are now processed when an interrupt entity is unhidden.

01 Jun 12 

Show

Pending interrupts are now processed when an interrupt entity is unhidden.
* The supported interrupts are RS2RXC, RS4RXC, AS1RXC, AS2RXC, DBGRXC, TWIRXC, SPIRXC, USBRXC, TIMER0..TIMER9
* Example
INT( intRs2, RS2RXC, fncRs2Rx ); // Create RS2 receive interrupt
...
HIDE( intRs2 ); // Hide the interrupt
...
SHOW( intRs2 ); // Show (Enable) interrupt and process pending interrupts
* If you don't want to process any pending interrupts when you show the interrupt then RESET the interrupt first
* Example
INT( intTmr0, TIMER0, fncTmr0 ); // Create RS2 receive interrupt
...
HIDE( intTmr0 ); // Hide the interrupt
...
RESET( intTmr0 ); // Clear any pending interrupts
SHOW( intTmr0 ); // Show (Enable) interrupt for future interrupts

49.02

 Key Interrupts - Fixed INT() command to handle K0..K9 format as well as K00..K09

15 May 12 

Show

Fixed INT() command to handle K0..K9 format as well as K00..K09

49.00

 Interrupts - Fixed problem with interrupts stopping after 255 interrupts

22 Mar 12 

Show

Fixed problem with interrupts stopping after 255 interrupts

47.04

 Timer Interrupts

26 Jul 11 

Show

Fixed problem with timer interrupt recursively re-entering when the timer is
reconfigured in the INT() handler.

44.00

 I/O Interrupts - Fixed issue when some I/O ports are setup as interrupts (K02,03,05,06,11,12,13 and 16-23).

20 May 11 

Show

Fixed issue when some I/O ports are setup as interrupts
(K02,03,05,06,11,12,13 and 16-23).

39.00

 Key IO - Fixed port mappings for 5.7'' and 7'' modules.

21 Jan 11 

Show

Fixed port mappings for 5.7" and 7" modules.

39.00

 Interrupts - Serial interrupts INT() can now be declared either globally or locally to a page.

21 Jan 11 

Show

Serial interrupts INT() can now be declared either globally (outside of a PAGE(){}) or locally to a page (inside a PAGE(){}).
If an interrupt is declared within a page then it will only be called when the page is being shown.
If an interrupt is declared outside of a page then it will be called no matter which page is being shown.
There is a special case when the same interrupt source is declared both globally and within a page.
In this case, the page interrupt takes precedence and the global interrupt is not called.

37.00

 Key IO - Bug fix to read all 32 pins.

13 Dec 10 

Show

Bug fix to read all 32 pins (was reading just first 8).

36.00

 Wait - WAIT() can now be used with INTs, VARs or PTR.

23 Nov 10 

Show

WAIT() can now be used with INTs, VARs or PTR.

35.00

 Key IO - Added INT functionality for IO inputs.

12 Nov 10 

Show

Added INT functionality for IO inputs. (not page / entity based yet so no deletion possible and action is global)
LOAD(Kxx, integer) now works (previously only worked using a source variable).
Single digit key names are now accepted (K0 - K9) (prev had to be K00 - K09).
Using U8 with IO write now works.

34.00

 Serial Port Interrupt Characters - Serial Port termination characters can now be specified to generate an interrupt.

19 Oct 10 

Show

Serial Port termination characters can now be specified to generate an interrupt. Changes applied to RS2, RS4, AS1, AS2, DBG, I2C, SPI ports
The proc parameter is used in the port setup to define the character
proc = all; <- trigger on all received characters
proc = CRLF; <- trigger on a CR followed by LF (0Dh 0A)
proc = CR; <- trigger on CR (0Dh)
proc = LF; <- trigger on LF (0Ah)
proc = NUL; <- trigger on NUL (00h)
proc = \\xx; <- trigger on xxh
proc = "ABCD"; <- string in format defined by SYSTEM encode param
proc = "\\xx\\xx"; <- string in format defined by SYSTEM encode param

In the following example, text is put on the screen when data followed by a semicolon is received on the serial port.

SETUP(RS2)
{ set = "192NY"; // 19200 bps, no parity, data mode
proc = ";"; // Interrupt triggered when a ';' is received
}

30.00

 Inline Command Blocks - enclosed in [...]'s - Commands that make calls to functions can now include the function code inline.

24 Sep 10 

Show

Commands that make calls to functions (RUN, IF, INT,KEY) can now include the function code inline by enclosing commands in square brackets [] or call a function.

IF( VarA op VarB ? [ CmdYA(); CmdYB(); ... CmdYn(); ] : [ CmdNA(); CmdNB(); ... CmdNn(); ] );

RUN( [ CmdA(); CmdB(); ... Cmdn(); ] );

INT( Name, Buf, [ CmdA(); CmdB(); ... Cmdn(); ] );

KEY( Name, [ CmdA(); CmdB(); ... Cmdn(); ], X, Y, Style );

Examples:
IF(VarA >= 50 ? [CALC(VarA,VarA,5,"-");TEXT(TxtA,VarA);;] : [LOAD(RS2,"VarA=",VarA);SHOW(PageN);] );

KEY(keyX,[CALC(varX,varX,1,"+");],123,12,stKey);

This reduces the number of lines in the file by almost 30% and keeps related code close to the action.

27.00

 Entity Pointers - Entity pointers have been added.

10 Sep 10 

Show

Entity pointers have been added.
STYLE( PtrData, DATA ) { type = pointer; }
VAR( EntPtr1, PtrData );

To set/change which entity the entity pointer is pointing to you enclose its name in quotes.
LOAD( "EntPtr1", "Var1" ); // Set EntPtr1 to point to "Var1"

To access the entity pointed to by the entity pointer, do not enclose is quotes.
LOAD( EntPtr1, "ABC" ); // Load the Entity pointed to
by EntPtr1 with "ABC"

The following commands now support entity pointers:
> LOAD(name|ptr|"ptr",num|"txt"|var|ptr,...);
> CALC(var|ptr,var|ptr,num|var|ptr,"op");
> TEXT(name|ptr,"txt"|var|ptr,...);
> IF(var|ptr op num|"txt"|var|ptr ? func|func_ptr : func|func_ptr);
> KEY(name,func|func_ptr,...);
> INT(name,buf,func|func_ptr,...);
> SHOW(name|ptr,...);
> HIDE(name|ptr,...);
> RUN(name|func_ptr,...);
> IMG(name|img_ptr,lib|img_ptr,...);

See the tu480.mnu file for an example of using pointers to update images representing CNTSECS.

24.00

 INT - Used to receive data from other interfaces other than host.

25 Aug 10 

Show

Used to receive data from other interfaces other than host
This is currently set to interrupt on each character received.
Use HIDE(Name); to disable an interrupt.
Added INT( Name, Buffer, Function ); where 'Buffer' can be:
> RS2RXC = RS232 Receive Character
> RS4RXC = RS485 Receive Character
> AS1RXC = Async1 Receive Character
> AS2RXC = Async2 Receive Character
> DBGRXC = Debug Receive Character
> I2CRXC = I2C Receive Character

NOTE: The Buffer must be read to clear the interrupt otherwise the Function will keep getting called!
Interrupts for counters, transmit, I/O triggers are to follow.