nrf52840 RCT2 configuration and usage

Hello,

I'm trying to enable RTC2 for nrf52840 DK to use as a date time clock and set/get over SMP protocol. RTC0 is used for MPSL, RTC1 is used by the system.

I configured MCU MGR option:

CONFIG_MCUMGR_GRP_OS_DATETIME=y

I configured RTC:

CONFIG_COUNTER=y
CONFIG_NRFX_RTC2=y
CONFIG_RTC=y

DTS for RTC2:

aliases {
		rtc = &rtc2;
	};
	
&rtc2 {
    status = "okay";
};

The command to set date-time works and return empty result. But when try to get date-time I see strange result. For instance:

{
  "datetime": "39997-165-36T05:168:00"
}

And now matter how many times I get it I see the same.

For me it looks like the RTC2 is not initialized. But i check it readiness in main:

if (!device_is_ready(rtc)) {
		printk("Device RTC is not ready\n");
		return 0;
	}
 

Anything I forget to do to use RTC2 as a date-time source?

Related