This is my new version, now using Timer1 to count 1/16 microseconds. As timer1 is a 16bit timer it counts to 65535 before it overflows so it can do 4096 usec max. That would suit your needs.
If it overflows it calls an interrupt and in the IRQ another int is incremented. These two (Timer1 counter + IRQ counter) together make effectively a long, resulting in max time of around 4 minutes. The code is not 100% tested and does sometimes strange - especially first pulse - but the results are promissing.
I have to "fiddle" which settings must be between the two while loops, and which can be before the first one.
Give it a try.
//
// FILE: PulseWidthMeter.pde
// AUTHOR: Rob Tillaart
// DATE: 2012-mar-28
//
// LINK: http://arduino.cc/forum/index.php?action=post;topic=96971.0
//
#include <avr/io.h>
#include <avr/interrupt.h>
volatile unsigned int cnt = 0;
void setup()
{
Serial.begin(38400);
Serial.println("PulseWidthMeter (timer1) 0.1");
pinMode(3, INPUT);
}
void loop()
{
// initialize Timer1
cli();
// reset counters
cnt = 0;
TCNT1 = 0;
// reset registers
TCCR1A = 0;
TCCR1B = 0;
// wait for HIGH
while ((PIND & B00001000) == B00000000);
// enable Timer1 overflow interrupt:
TIMSK1 = (1 << TOIE1);
// Set CS10 bit so timer runs at clock speed: 16 MHz
TCCR1B |= (1 << CS10);
// enable global interrupts:
sei();
// keep counting until LOW
while ((PIND & B00001000) == B00001000);
// stop IRQ's
cli();
// Read the counters and convert to long
unsigned int x = TCNT1; // work copy
unsigned long total = cnt * 65535L + x;
float usec = (1.0 * total) / 16;
// Display values
Serial.print(total, DEC);
Serial.print(" \t ");
Serial.println(usec, 1);
// Wait a while
delay(1000);
}
// count the overflows in IRQ
ISR(TIMER1_OVF_vect)
{
cnt++;
}