Hello,
I'm trying to run a simple example setting the RTC1 in a nRF52840-DK, but I'm having some issues.
Here is my prj,conf and code:
# nothing here CONFIG_PM=y CONFIG_PM_DEVICE=y CONFIG_NRFX_RTC1=y
#include <zephyr/kernel.h>
#include <nrfx_rtc.h>
#include <nrfx_timer.h>
#define RTC_INSTANCE 1
#define ALARM_PERIOD_SECONDS 2
static nrfx_rtc_t rtc = NRFX_RTC_INSTANCE(RTC_INSTANCE);
void rtc_event_handler(nrfx_rtc_int_type_t int_type)
{
if (int_type == NRFX_RTC_INT_COMPARE0) {
// Handle RTC event here
printk("RTC event occurred\n");
}
}
void main(void)
{
printk("Hello World!\n");
nrfx_rtc_config_t config = NRFX_RTC_DEFAULT_CONFIG;
config.prescaler = RTC_FREQ_TO_PRESCALER(1);
nrfx_rtc_init(&rtc, &config, rtc_event_handler);
nrfx_rtc_tick_enable(&rtc, true);
uint32_t alarm_ticks = ALARM_PERIOD_SECONDS;
nrfx_rtc_cc_set(&rtc, 0, alarm_ticks, true);
nrfx_rtc_enable(&rtc);
}
The idea above is set the prescaler to 1 second and fire at every 2 seconds.
The RTC handler is simply not firing, as follows:

Can you help me to figure out what is missing? Code attached.