8000 nrf5/hal: hal_rtc update. Adding current counter value to period valu… · godlygeek/circuitpython@c301cca · GitHub
[go: up one dir, main page]

Skip to content

Commit c301cca

Browse files
committed
nrf5/hal: hal_rtc update. Adding current counter value to period value before setting it in the compare register.
1 parent f50a56d commit c301cca

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

nrf5/hal/hal_rtc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ void hal_rtc_init(hal_rtc_conf_t const * p_rtc_conf) {
4949
}
5050

5151
void hal_rtc_start(hal_rtc_conf_t const * p_rtc_conf, uint16_t period) {
52-
p_rtc_conf->p_instance->CC[0] = period;
52+
uint32_t counter = p_rtc_conf->p_instance->COUNTER;
53+
54+
p_rtc_conf->p_instance->CC[0] = counter + period;
55+
5356
p_rtc_conf->p_instance->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
5457
p_rtc_conf->p_instance->INTENSET = RTC_INTENSET_COMPARE0_Msk;
5558

@@ -60,12 +63,12 @@ void hal_rtc_start(hal_rtc_conf_t const * p_rtc_conf, uint16_t period) {
6063
}
6164

6265
void hal_rtc_stop(hal_rtc_conf_t const * p_rtc_conf) {
63-
p_rtc_conf->p_instance->TASKS_STOP = 1;
64-
6566
p_rtc_conf->p_instance->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
6667
p_rtc_conf->p_instance->INTENCLR = RTC_INTENSET_COMPARE0_Msk;
6768

6869
hal_irq_disable(p_rtc_conf->irq_num);
70+
71+
p_rtc_conf->p_instance->TASKS_STOP = 1;
6972
}
7073

7174
void RTC0_IRQHandler(void)

0 commit comments

Comments
 (0)
0