-1

I am building a stopwatch that must have a millisecond precision. The precision of the millis () function of arduino is not sufficient to guarantee a good result.

I read this answer:

How to get millisecond resolution from DS3231 RTC

But it does not work because the DS3231 option 2 frequency in not 1KHz but 1Hz. Then the code count the seconds not the milliseconds.

How can I solve?

Thank you

dmirko
  • 7
  • 1
  • 1
    How long is your stop watch period? I would use the internal clock if you are watching no longer than a couple of minutes. An external quartz is necessary to have a stable clock for a long period of time. For short periods, the internal clock drift is usually neglectable – ooxi Feb 26 '18 at 16:59
  • From ten seconds to five minutes. – dmirko Feb 26 '18 at 19:45
  • in this case I suggest to reconsider whether or not the internal clock is sufficient. If not, use the DS3221 RTC in the configuration suggested by my answer :-) – ooxi Feb 26 '18 at 19:50

1 Answers1

0

If you really need millisecond accuracy, I suggest using the DS3221 RTC in the following configuration

RS2 = 0
RS1 = 1

This gives you a resolution of 1024 Hz which you can fairly easily convert to milliseconds.

ooxi
  • 3,159
  • 2
  • 28
  • 41