High Accuracy Timer


Senior Member
This is a high accuracy timer which uses a 20X2 to measure the time a gated clock pulse is present. Using 64MHz operating speed it has a timing period in excess of 18 hours, accurate to below 125ns.

The program includes auto-generation of a clock signal using PWMOUT ( up to 8MHz ) which can be gated to the clock input using just a push button. Possibly the most accurate push button timer so far :)



New Member
Could this be used as a stop watch

Hi Hippy

I am newish to this site and have enjoyed learning about pixace.

Your code looks very interesting although its very advanced for me.

I am trying to build a timer (stopwatch) to measure the speed of an object between two points. So would need to measure the time to 0.001 of a second i would think, unless your code goes better than that.

I hope to use to lasers as the switches to start and stop the timer. Setting the laser at a know distance would be vital, though i will practice with infrared to start with.

I am using serial4 x 20 LCD in my first project with work well

My code will then work out the speed in m/s or some other miles/hour etc

I think your code gives me the accurate clock (timer) that i would need.

I have tried your code through the simulate in editor but cant find out how to start and stop the timer.

Any advice would be welcome.


Senior Member
There are a number of other projects which have dealt with measuring speed as an object passes between two points. A Forum Search will help there, with one thread I could find which will be useful being -


In my code you don't have to really worry about turning the timer on and off, it's more a counter of pulses which only occur when the clock signal is routed through to the timer acting as a counter. You'd use the two timing points to make the connection and then break it, the count during that time is then used to determine the speed.

I am not sure the code will simulate well as it relies on the physical hardware of the chip which the simulator cannot emulate.


Senior Member
This is a really great project an accurate timer for a 20x2 and just a few wires. The logic I generally understand but trying to convert this to an accurate stopwatch with start/lap/stop times display and failing to even set the program up so it runs and just update the timer when a pin goes high, if someone would be willing to help a novice in over his head it would be appreciated.