projector - delay function screws rpm measurement

Tom, I have hacked the following out of some code I use that I think is similar to your application. I hope it helps.

The first function configures timer1 to count in half microsecond steps.

The second waits until the given number of microseconds have elapsed. Interrupts are neither used nor blocked, but that means that if an interrupt occurs just as the timer count threshold is reached there will be a little extra delay for the interrupt service routine to finish.

void configTimer1(){
  // call this from setup to configure timer1 to count in half microseconds ticks
  TCCR1A = 0x00;      // COM1A1=0, COM1A0=0 => Disconnect Pin OC1 from Timer/Counter 1 -- PWM11=0,PWM10=0 => PWM Operation disabled 
  TCCR1B = 0x02;      // 16MHz clock with prescaler means TCNT1 increments every .5 uS (cs11 bit is set)
  TIMSK1 = 0x00;      // Timer1 interrupts off  
}
/*************************************************************************************/
void waitMicroSeconds(unsigned int Microseconds){   // returns after the given number of microseconds have elapsed
// longest delay is just over 30 milliseconds 

     TCNT1 = 0;                          //reset timer
     SET_PULSE_HIGH(OutPort, OutBit); 
     OCR1A = Microseconds  *  2;            // timer is counting in 500ns steps 
     TIFR1 = (1<<OCF1A);                  //Clear the compare A flag 
     uint8_t ocFlag = 1<<OCF1A ;
     while( ! (TIFR1 & ocFlag) )          // Wait for output compare flag 
            ;             
}