RTC Initialization fails (NRF_ERROR_ALREADY)

Hi,

I'm trying to use an RTC with the nRF Connect SDK (v2.9.0) and nRF52840, but nrfx_rtc_init always returns the error NRF_ALREADY_INIT. I haven't used the RTC anywhere else in my code, and I also tried using RTC0, but I still get the same error."

Fullscreen
1
2
3
4
5
6
const nrfx_rtc_t rtc = NRFX_RTC_INSTANCE(2);
nrfx_err_t err;
nrfx_rtc_config_t rtc_cfg = NRFX_RTC_DEFAULT_CONFIG;
if (nrfx_rtc_init(&rtc, &rtc_cfg, rtc_event_handler))
err = nrfx_rtc_init(&rtc, &rtc_cfg, rtc_event_handler);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The project configuration file is below:

Fullscreen
1
2
3
4
5
6
7
8
9
10
CONFIG_NRFX_SAADC=y
CONFIG_NRFX_PPI=y
CONFIG_NRFX_TIMER4=y
CONFIG_NRFX_TEMP=y
CONFIG_NRFX_PWM0=y
CONFIG_NRFX_RTC2=y
# Enable DK LED and Buttons library
CONFIG_DK_LIBRARY=y
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I'm using the nrfx library because I need to link it with the PPI module, which I believe is not supported in Zephyr.