Millisecond stopwatch

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello, I am trying to create an accurate millisecond stopwatch which records the timing of external triggers. I would like to be able to record hours long samples but accurately time the stopwatch down to milliseconds. 

   

At the moment, I feel like my counter (see attached) is not recording accurately. 

   

For testing, my project has an internal 1s PWM, which when measured on a  scope is quite accurate.

   

This PWM fires an interrupt, which reads my Counter (which counts on an 1kHz clock). The main loop then prints this count number to my LCD, as well as the difference from the previous reading. I have as minimal work between interrupt fire and counter read as I can. 

   

The problem is, when I print the difference to my screen for the every 1s count read, I consistently get a difference of 993 counts, instead of the 1000 counts I expect. 

   

 

   

Can anyone offer any advice on how to improve the accuracy of my stopwatch counter? 

0 Likes
9 Replies