
//=============================================
// T2 is set for a 1ms interrupt in auto-reload

void timer2_int(void) interrupt 5 using 2
{
  TF2 = 0;
  ++checkCount;            // count of ms
  ++msTick_1 ;             // count of general purpose delay
}  
//=============================================

//Part of Main code for checkout. No other part is active..

 while(1)
   { 
     LedFlash(); 
                   
     // checkCount is the actual delay in ms.

     if (toggle==0)
     sprintf (string, "%s%d","LED OFF:", checkCount );
     else
     sprintf (string, "%s%d","LED ON: ", checkCount );
     display(string);
     checkCount = 0;
   } 
//===============================================

void LedFlash (void)
{
    msDelay(1000);       // Flash Interval 

    DOT_3 = ~DOT_3;      // Change LED state for every call
    toggle = ~toggle;    // Flag to change On/Off message

}

//================================================
//Time delay function. Call with required ms delay

 void msDelay (int DelayVal)
{
  TR2 = 1;
  while ( msTick_1 < DelayVal); // msTick1 inc.by timer2_int
  msTick_1 = 0;
  TR2 = 0;
}
//================================================
