From 3ea75d13143521a6e2b1b5ce594b819d8d0e2202 Mon Sep 17 00:00:00 2001
From: Thomas Stilwell <stilwellt@openlabs.co>
Date: Sun, 13 Jan 2019 17:38:57 -0800
Subject: [PATCH] cpu/kinetis/rtt: clear subseconds when writing seconds

---
 cpu/kinetis/periph/rtt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cpu/kinetis/periph/rtt.c b/cpu/kinetis/periph/rtt.c
index 4bbf3240d0..ee22cf63f5 100644
--- a/cpu/kinetis/periph/rtt.c
+++ b/cpu/kinetis/periph/rtt.c
@@ -110,6 +110,8 @@ void rtt_set_counter(uint32_t counter)
 {
     /* Disable time counter before writing to the timestamp register */
     bit_clear32(&RTC->SR, RTC_SR_TCE_SHIFT);
+    RTC->TPR = 0;
+    /* write TSR after TPR, as clearing TPR bit 14 will increment TSR */
     RTC->TSR = counter;
     /* Enable when done */
     bit_set32(&RTC->SR, RTC_SR_TCE_SHIFT);
-- 
GitLab