|   | DT_INTS-14 (Elapsed Timer) Here's an example of just the Elapsed Timer by itself. 
      Example 2:
     INCLUDE "DT_INTS-14.bas"
INCLUDE "ReEnterPBP.bas"
INCLUDE "Elapsed_INT.bas"  ; Elapsed Timer Routines
ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
    endm
    INT_CREATE            ; Creates the interrupt processor
ENDASM
@   INT_ENABLE  TMR1_INT  ; Enable Timer 1 Interrupts  
GOSUB ResetTime           ' Reset Time to  0d-00:00:00.00
GOSUB StartTimer          ' Start the Elapsed Timer
Main:
  IF SecondsChanged = 1 THEN  
     SecondsChanged = 0
     LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
  ENDIF
GOTO Main | 
| This will create a Clock counting at 1/100 seconds. It runs in the background of PBP without any other program intervention required. The time is kept in the variables:     Ticks    var byte   ' 1/100th of a second
    Seconds  var byte   ' 0-59
    Minutes  var byte   ' 0-59
    Hours    var byte   ' 0-23
    Days     var word   ' 0-65535
The time can be easily displayed with a single line: LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds For each of the variables (Seconds, Minutes, Hours and Days) there is a flag that indicates when the value of that variable has changed. The Flags are:     SecondsChanged   var bit
    MinutesChanged   var bit
    HoursChanged     var bit
    DaysChanged      var bit
If you wanted to display the time like a clock, you could wait until SecondsChanged = 1, display the time, then reset the flag.     Loop:
        if SecondsChanged = 1 then
           LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds
           SecondsChanged = 0
        endif
    Goto LoopIf you only wanted to display the time each minute instead of every second just do the same thing using the MinutesChanged flag.     Loop:
        if MinutesChanged = 1 then
           LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes
           MinutesChanged = 0
        endif
    Goto LoopThe timer can be Stopped and Started, like a stopwatch.     Gosub StopTimer
    Gosub StartTimer
 |