Hi!
I'm not good at C and microcontrollers programming. Could somebody clarify, if nrf_rtc_counter_get interrupt safe? It just reads value from rtc register->COUNTER (24bit), how many ticks it takes?
Thanks.
Hi!
I'm not good at C and microcontrollers programming. Could somebody clarify, if nrf_rtc_counter_get interrupt safe? It just reads value from rtc register->COUNTER (24bit), how many ticks it takes?
Thanks.
Hi,
Could somebody clarify, if nrf_rtc_counter_get interrupt safe? It just reads value from rtc register->COUNTER (24bit), how many ticks it takes?
As you mention, it reads the ->COUNTER register. It does not guard (disable / enable) against any interrupt that might occur while reading the register.
You can call this from any priority.
One tick is one cycle on the RTC (32.768k), and the register is read via the CPU, so it'll take alot less time than one tick to read. See Turbo J's excellent answer on this.
If you have a function that should not be interrupted, you can use the macros "CRITICAL_REGION_ENTER()" and "CRITICAL_REGION_EXIT()" to guard that function.
Kind regards,
Håkon
Hi, I posted question under latest answer, maybe you didn't notice it. https://devzone.nordicsemi.com/f/nordic-q-a/59937/is-nrf_rtc_counter_get-interrupt-safe/243846#243846
Hi,
It s a free-running timer, not tied to the CPU at all. Yes, you can read it out two consecutive times and get different value, for instance that the RTC has incremented its counter just after the first read, or if you have an interrupt occurring between the two reads.
Kind regards,
Håkon
Hi,
It s a free-running timer, not tied to the CPU at all. Yes, you can read it out two consecutive times and get different value, for instance that the RTC has incremented its counter just after the first read, or if you have an interrupt occurring between the two reads.
Kind regards,
Håkon