I am working on an nRF54L15 project and started from:
C:\ncs\v3.0.2\nrf\samples\bluetooth\peripheral_uart
as the base. I would like to trigger an interrupt once every second.
Since the documentation says RTC consumes less power than the timer, I don’t want to use k_timer_start to generate the interrupt. Instead, I want to use RTC.
From:
C:\ncs\v3.0.2\zephyr\boards\nordic\nrf54l15dk\nrf54l_05_10_15_cpuapp_common.dtsi
I saw that grtc is defined, so I tried to use the following code to set up an interrupt.
void Set1secAlarm(void);
static void grtc_alarm_callback(const struct device *dev,
uint8_t chan_id,
uint32_t ticks,
void *user_data)
{
ARG_UNUSED(dev);
ARG_UNUSED(chan_id);
ARG_UNUSED(ticks);
ARG_UNUSED(user_data);
Set1secAlarm();
}
void Set1secAlarm(void)
{
struct counter_alarm_cfg alarm_cfg = {
.flags = COUNTER_ALARM_CFG_ABSOLUTE,
.ticks = counter_ticks_to_us(grtc_dev, TICK_INTERVAL_SEC),
.callback = grtc_alarm_callback,
};
counter_set_channel_alarm(grtc_dev, 0, &alarm_cfg);
}
int RTC_init(void)
{
if (!device_is_ready(grtc_dev))
{
LOG_ERR("GRTC device not ready");
return -1;
}
counter_start(grtc_dev);
Set1secAlarm();
return 0;
}However, I always run into compilation errors.
Here is the error log:
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map D:/Project/PetLoc8/build/PetLoc8/zephyr/zephyr_pre0.map
cmd.exe /C "cd . && C:\ncs\toolchains\0b393f9e1b\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf -L"c:/ncs/toolchains/0b393f
9e1b/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main/nofp" -lc -lgcc && cmd.exe /C "cd /D D:\Project\PetLoc8\build\PetLoc8\zephyr && C:\ncs\toolchains\0b393f9e1b\o
pt\bin\cmake.exe -E true""
c:/ncs/toolchains/0b393f9e1b/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(RTC.c.obj):D:/Project/PetLoc8/Component/RTC/R
TC.c:16: undefined reference to `__device_dts_ord_79'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
[10/20] No configure step for 'mcuboot'
FAILED: _sysbuild/sysbuild/images/PetLoc8-prefix/src/PetLoc8-stamp/PetLoc8-build D:/Project/PetLoc8/build/_sysbuild/sysbuild/images/PetLoc8-prefix/src/PetLoc8-stamp/PetLoc8-build
cmd.exe /C "cd /D D:\Project\PetLoc8\build\PetLoc8 && C:\ncs\toolchains\0b393f9e1b\opt\bin\cmake.exe --build ."
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\0b393f9e1b\opt\bin\cmake.EXE' --build D:/Project/PetLoc8/build
So, my questions are:
-
Am I misunderstanding something — does the nRF54L15 not actually support RTC alarm?
-
If it does, what is the correct way to configure it so I can get a 1-second periodic interrupt?
Thanks!