  
void main(void)
  {
    union merge {tChar hilo[4]; tLong regval;} t1val;                 
    ...
    ...
    while(1)
    {
    msDelay(100);               // One update every 0.1sec  
     
    while (RPMCLK == 0);        // [A]wait to clear the partial low of clock
    while (RPMCLK == 1);        // [B]wait to clear the partial high of clock
        
    TR1 = 1;                    // start timer_1 to count MCU clock pulses

    while (RPMCLK == 0);           [C] start counting the 1micro pulses
    while (RPMCLK ==1);	       //  [D] continue counting for 1 full period
 
    TR1 = 0 ;                  // stop counting. 

    tmpResult = ovrfloCnt * 65536 ;  // Get the total period of overflows
		
    t1val.hilo[3] = TL1;       // (LSB) merge TL1 and TH1 into a long int... 
    t1val.hilo[2] = TH1;       //     ... to get the residual count
    t1val.hilo[1] = 0;
    t1val.hilo[0] = 0;         // (MSB)	
		
    t1val.regval = t1val.regval + tmpResult;				

    tmpResult = 2000000 / t1val.regval; // Transfer function to get RPM
      
    sprintf(dispBuffer, "%04lu", tmpResult ); // Display the value..

    ...
    ...
  }
 }
