From 146e3c4c66c05de21409a63cacab9e8401bb1959 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Tue, 6 Aug 2019 14:06:50 -0400 Subject: 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. --- src/rtc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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(); -- cgit v1.2.3