diff options
| author | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-03-06 20:51:59 +0100 |
|---|---|---|
| committer | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-03-06 20:52:09 +0100 |
| commit | c301cca2a4e2b4efe2d47a52929de15b02beb598 (patch) | |
| tree | 1732c8584d1b3e4f509a78dbda1a6d9c3b671c5f | |
| parent | f50a56dbb58f2089fc75ab3a4f5f83e1395bdc21 (diff) | |
nrf5/hal: hal_rtc update. Adding current counter value to period value before setting it in the compare register.
| -rw-r--r-- | nrf5/hal/hal_rtc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/nrf5/hal/hal_rtc.c b/nrf5/hal/hal_rtc.c index bf10dfc8d..d539d78c4 100644 --- a/nrf5/hal/hal_rtc.c +++ b/nrf5/hal/hal_rtc.c @@ -49,7 +49,10 @@ void hal_rtc_init(hal_rtc_conf_t const * p_rtc_conf) { } void hal_rtc_start(hal_rtc_conf_t const * p_rtc_conf, uint16_t period) { - p_rtc_conf->p_instance->CC[0] = period; + uint32_t counter = p_rtc_conf->p_instance->COUNTER; + + p_rtc_conf->p_instance->CC[0] = counter + period; + p_rtc_conf->p_instance->EVTENSET = RTC_EVTEN_COMPARE0_Msk; p_rtc_conf->p_instance->INTENSET = RTC_INTENSET_COMPARE0_Msk; @@ -60,12 +63,12 @@ void hal_rtc_start(hal_rtc_conf_t const * p_rtc_conf, uint16_t period) { } void hal_rtc_stop(hal_rtc_conf_t const * p_rtc_conf) { - p_rtc_conf->p_instance->TASKS_STOP = 1; - p_rtc_conf->p_instance->EVTENCLR = RTC_EVTEN_COMPARE0_Msk; p_rtc_conf->p_instance->INTENCLR = RTC_INTENSET_COMPARE0_Msk; hal_irq_disable(p_rtc_conf->irq_num); + + p_rtc_conf->p_instance->TASKS_STOP = 1; } void RTC0_IRQHandler(void) |
