Command TIMER
 
Description Twenty (20) count-down timers with 1ms resolution - TIMER0 to TIMER19 - v49.25
 
Syntax/Parameters TIMER0 - TIMER19
 
Options

To setup the interrupts:
   
    INT(name,TIMER0,function); to INT(name,TIMER19,function);

To read the remain time before expiry
        LOAD(var,TIMER0);
   
To run  the timer once
        LOAD(TIMER0,time);   // time is in milliseconds

To run the timer multiple times
        LOAD(TIMER0,time,num);     // time is in milliseconds
        num is number of times timer runs, 1 = 1 time, 2 = 2 times etc, 0 = non-stop
      
To clear the timer
        LOAD(TIMER0,0);

 
Example LOAD(TIMER6,1000);     // TIMER6 runs once and expires after one second
LOAD(TIMER9,1000,0);  // TIMER9 runs forever, expiring every second
LOAD(TIMER14,500,5);  // TIMER14 runs five times, expiring every 500ms
LOAD(TIMER3,0);          // Clear TIMER3
LOAD(TIMER17,time);    // TIMER17 runs once and expires after value in var time
 
Update Information

 Version

 Title

Date  

 Details

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.25

 Timers - Increased number of built-in timers from 10 to 20 ranging TIMER0..TIMER19

01 Nov 12 

Show

* Increased number of built-in timers from 10 to 20 ranging TIMER0..TIMER19

49.06

 Internal Timer - General internal timer value made a volatile to guarantee correct value read.

29 Jun 12 

Show

General internal timer value made a volatile to guarantee correct value read.

49.00

 Interrupts - Fixed problem with interrupts stopping after 255 interrupts

22 Mar 12 

Show

Fixed problem with interrupts stopping after 255 interrupts

49.00

 Error Interrupt Handlers - Code now jumps to error handlers for Prefetch Abort, Data Abort, SWI, and Undefined Interrupts.

22 Mar 12 

Show

Code now jumps to error handlers for Prefetch Abort, Data Abort, SWI, and Undefined Interrupts.

48.24

 Timers - Fixed problem with loading timer when timer name specified in lowercase.

10 Mar 12 

Show

Fixed problem with loading timer when timer name specified in lowercase.
Fixed problem with processing fast timer interrupts which caused application to sit in loop processing timer functions.

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.

45.00

 Timers (TIMER0 - TIMER9) - Ten (10) count-down timers with 1ms resolution have been added, TIMER0 to TIMER9

10 Jun 11 

Show

Ten (10) count-down timers with 1ms resolution have been added, TIMER0 to TIMER9

To setup the interrupts:
INT(name,TIMER0,function); to INT(name,TIMER9,function);

To read the remain time before expiry
LOAD(var,TIMER0);

To run the timer once
LOAD(TIMER0,time); // time is in milliseconds

To run the timer multiple times
LOAD(TIMER0,time,num);
time is in milliseconds
num is number of times timer runs, 1 = 1 time, 2 = 2 times etc, 0 = non-stop

To clear the timer
LOAD(TIMER0,0);

LOAD(TIMER6,1000); // TIMER6 runs once and expires after one second
LOAD(TIMER9,1000,0); // TIMER9 runs forever, expiring every second
LOAD(TIMER4,500,5); // TIMER4 runs five times, expiring every 500ms
LOAD(TIMER3,0); // Clear TIMER3
LOAD(TIMER7,time); // TIMER7 runs once and expires after value in var time