Issue with reading serial data

Anand_kumar:
Sure, I have posted the code below.

[......]

I start reading the data at equal intervals of time(thereby 8us for the case of 16us time period signal,

That code is still using digitalRead()

Also I thought you want to work with a pulse width of 4µsecs?

It would make a lot more sense to use a RISING interrupt to detect the first pulse - and maybe even ALL of the pulses.

And what is the ultimate purpose of all this. It's a lot of trouble to go to just to check a square wave from a signal generator.

...R