Thanks for your reply and letting me know about that, that's what I was also thinking that may be I can't use higher clocks so the only solution now for me is to use a external fast counter since I have to measure the width accurately and the pulses are just too short 8-15 microseconds. I have a algorithm in arduino but that is not good since it takes one count every microsecond so it cannot measure widths accurately and I need a high resolution so I need to use some external fast counter with arduino so any ideas about that? Here is my code which is doing a count every microsecond
#include<stdlib.h>
unsigned int pulse_counts = 0;
char buffer[20];
char buffer2[20];
char s[4]=" , ";
unsigned int count = 0;
void setup()
{
Serial.begin(9600);
// Serial.println("pulse width measurment");
pinMode(3, INPUT);
}
void loop()
{
count = 0;
pulse_counts++;
while ((PIND & B00001000) == B00000000); // wait for HIGH
while ((PIND & B00001000) == B00001000) count++; // start counting until LOW
float usec = 1.0 * count * 0.50;
// For text file output - Uncomment this
// Serial.print("#S|AAA|[");
// Serial.print(dtostrf(usec,5,2,buffer));
// Serial.print(s);
// Serial.print(itoa((pulse_counts), buffer2, 10));
// Serial.println("]#");
// For serial output display - Uncomment this
Serial.print("Count = ");
Serial.print(pulse_counts);
Serial.print(" , Width = ");
Serial.print(usec, 2);
Serial.println (" microseconds");
// delay(1000);
}