I am using an NRF52840 custom board with a high quality crystal on the low frequency clock.
I see that to configure this I should specify the following in the .conf file:
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y
My question is simply, "What is the best way to query the value of this clock". Seems a simple question, but looking at the
documentation and this forum, there is just a mind-boggling number of possible answers given.
Here are the possibilites I have come up with so far:
1)
k_uptime_get(); Does this actually query this clock, or is it using the program counter's clock?
2)
k_uptime_ticks();
3)
CONFIG_COUNTER=y in .conf, and
counter_start(); followed by
counter_get_value();
4)
From the samples/subsys/logging/logger, though its really unclear where NRF_RTC1 comes from.
NRF_RTC1->COUNTER;
5)
nrfx_rtc_counter_get(); // from nrfx_rtc.h
6)
z_nrf_rtc_timer_read(); // from the timer tests
Questions:
Which of these actually are based on the LFCLK?
Which are recommended?
Which of these are best for low power consumption?
Which of these will continue to count if the SOC is put in a low-power mode?
What if the main thread is put to sleep waiting on an interrupt, will it keep counting?
How does the following effect the recommended call, if at all?
- Using an app timer
- Using a watchdog timer
- Using BLE
- Using MPSL