clocksync: Change timer frequency to avoid resonating with other timers

If the clock querying messages occur at a similar frequency to other
events on the micro-controller or host, then it's possible for the
load created by those other events to skew the clock synchronization.
In particular, the 500ms lcd screen update could resonate with the 1
second clock query.  Use an unusual clock querying frequency to avoid
this issue.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-05-05 20:14:46 -04:00
parent cd9e21e3aa
commit 640ff1ad56
1 changed files with 4 additions and 2 deletions

View File

@ -54,10 +54,12 @@ class ClockSync:
if pace: if pace:
freq = self.mcu_freq freq = self.mcu_freq
serial.set_clock_est(freq, self.reactor.monotonic(), 0) serial.set_clock_est(freq, self.reactor.monotonic(), 0)
# MCU clock querying (status callback invoked from background thread) # MCU clock querying (_handle_status is invoked from background thread)
def _status_event(self, eventtime): def _status_event(self, eventtime):
self.status_cmd.send() self.status_cmd.send()
return eventtime + 1.0 # Use an unusual time for the next event so status messages
# don't resonate with other periodic events.
return eventtime + .9839
def _handle_status(self, params): def _handle_status(self, params):
# Extend clock to 64bit # Extend clock to 64bit
last_clock = self.last_clock last_clock = self.last_clock