This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using RTC to get real time for nRF9160DK

Hi Dev team,

I had an issue regarding getting the real time using RTC. I tried to follow the below dev zone blog but the CAL_RTC does not work in my code.

As such, I am unable to use this to build my application. Does nR9160DK not support "CAL_RTC" like "NRF_CLOCK" .

Can you let me know how I could use the below code to build my app for nRF9160DK.

https://devzone.nordicsemi.com/f/nordic-q-a/51781/rtc-31st-date-problem-in-nrf52840

Also, a question regarding RTC and LFCLK. How can I view the real time value using RTC and LFCLK.

I can see in the debugger that they are running but I need to know the real time through it. Some help in explaining this would be appreciated :).

Regards,

Adeel.

Parents Reply
  • Hi Adeel

    I updated the Rallare RTC example to update the CC register as you describe, and it seems to work fine for me. 

    The only change I did was to update the rtc_handler function like this:

    static void rtc_handler(nrfx_rtc_int_type_t int_type)
    {
    	int rtc_value;
    	if (int_type == NRFX_RTC_INT_COMPARE0) {
    		nrf_gpio_pin_toggle(LED_0);
    
    		// Get the current counter value, add COMPARE_COUNTERTIME * 8, and update the CC 0 register
    		rtc_value = nrfx_rtc_counter_get(&rtc);
    		rtc_value += COMPARE_COUNTERTIME * 8;
    		nrfx_rtc_cc_set(&rtc, 0, rtc_value, true);
    
    	} else if (int_type == NRFX_RTC_INT_TICK) {
    		nrf_gpio_pin_toggle(LED_1);
    	}
    }

    Flashing the code I can see LED1 on the DK (referred to as LED_0 in the code) blink every few seconds. 

    Best regards
    Torbjørn

Children
Related