variables for time

is there anyone who knows how to work out time using a variable i would like to run a variable for example - varA to run increasing by 1 for 10 mins ?

how would i work out what Variable to set ?

is this possible ?

or any over advice on this would be great thanks in advance


Senior Member

A variable name "VarA" suggests that you might be using an "alternative" Programming method such as Blockly or a Flowchart, but the principle should be the same. Basically you can just use a loop which increments the variable counter and then includes a PAUSE or WAIT for an appropriate delaying time. For example:
SYMBOL VarA = w1
VarA = 0
   VarA = VarA + 1    ; Increment once each second
   PAUSE 998             ; Wait (almost) one second
;     Do anything else here [e.g. SERTXD (#VarA," ") ]
LOOP UNTIL VarA = 600     ; 10 Minutes if incremented once each second
The PAUSE 998 allows about 2 ms for the execution time of the other instructions in the loop, but in this example is not essential ; a PAUSE 1000 or WAIT 1 would be just as good.

Cheers, Alan.


Senior Member

Attached is code that demonstrates how EnableTime /Time can be used on M2 Parts to Increment a Variable every 10 minutes without using pauses.
Code has been tested on silicon and is accurate to +- 1 sec over 10 minutes( or better). Assumes operation at 4 MHz but can be easily adjusted to work at 4,8,16 or 32MHz.