Square Wave length as nanosecond

Hello. I want to measure square wave length as nanosecond precision and sense changing as nanosecond. How can i do it ? I used pulseIn but it s for microsecond scale. How can i measure a square wave length as nanosecond precision? Thanks.

Buy yourself an extremely good frequency counter.
An Arduino cannot do this.

I have ESP for it but i couldnt find sample code

1 ns = 10-9s

To measure time at that resolution you need a 1 GHz clock speed or better.

Now you know why you won’t find code for that kind of resolution. I’ve done 12.5ns resolution on an ESP8266, can probably cut that in half by clocking it at 160 MHz, but that’s really it.

Build a circuit to do the measurement, then relay the data to the Arduino to display.

Why do you need to do this ?

asddsa11:
Hello. I want to measure square wave length as nanosecond precision and sense changing as nanosecond. How can i do it ? I used pulseIn but it s for microsecond scale. How can i measure a square wave length as nanosecond precision? Thanks.

Always a good idea to explain why you want to do something.

Forum members are very experienced and could provide alternatives if you explained why you want to do something.

asddsa11:
Hello. I want to measure square wave length as nanosecond precision and sense changing as nanosecond. How can i do it ? I used pulseIn but it s for microsecond scale. How can i measure a square wave length as nanosecond precision? Thanks.

You could use something like the GP22 (and some ancillary electronics) to measure the duration of the square wave. I used one to measure signal reflection times in a cable and could detect the cable length (between 30m and 1m) to within a cm.