summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-06 14:06:50 -0400
committerBrian Cully <bjc@kublai.com>2019-08-06 14:06:50 -0400
commit146e3c4c66c05de21409a63cacab9e8401bb1959 (patch)
treece09d87a39d2989308272058b96abd32fe5cdcba
parentd3480939692c24d86d38cc7db70f04ccc76c1493 (diff)
downloadbleusb-146e3c4c66c05de21409a63cacab9e8401bb1959.tar.gz
bleusb-146e3c4c66c05de21409a63cacab9e8401bb1959.zip
Tweak RTC timer a bit.
This seems to get it closer to what the Arduino thinks is a millisecond. Measured by dumping timestamps on the Arduino with Linux timestamps. There is a fair amount of variance in the Arduino's serial output timing, but this is also close to what Linux thinks is ok. It's still slow by about ~5%, but I'm not sure how to correct it better, or if it's even worth bothering since everything is so imprecise anyway.
-rw-r--r--src/rtc.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rtc.rs b/src/rtc.rs
index 79e450a..fa7b347 100644
--- a/src/rtc.rs
+++ b/src/rtc.rs
@@ -21,8 +21,9 @@ impl Clock {
static CLOCK: Clock = Clock::new();
-// Set to run every ~500µs.
-static COUNTER: u32 = 16; // 32 ticks requires 1024 cycles at 32,768Hz for 1 second.
+// Set to run every ~500µs. This has been loosely calibrated from a
+// nrf52 clock running Arduino and a Linux host.
+static COUNTER: u32 = 13;
pub fn setup(mut rtc: RTC, clocks: &mut GenericClockController) -> impl FnMut() {
let rtc_clock = &clocks.gclk1();