<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>RTC Time Discrepancy Issue with nRF5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114354/rtc-time-discrepancy-issue-with-nrf5340</link><description>Hello all, 
 We are currently working with the nRF5340 on a custom board and have encountered an issue with the Real-Time Counter (RTC) using the nrfx libraries. The problem is that the RTC is not syncing correctly with the actual time. 
 For example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Sep 2024 11:59:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114354/rtc-time-discrepancy-issue-with-nrf5340" /><item><title>RE: RTC Time Discrepancy Issue with nRF5340</title><link>https://devzone.nordicsemi.com/thread/500967?ContentTypeID=1</link><pubDate>Tue, 03 Sep 2024 11:59:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b305d6f-0bdd-406a-b675-edc97a5bf343</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Instead of using the RTC(real time&amp;nbsp;counter peripheral) directly like that, you could try using e.g. the&amp;nbsp;RTC emulated device driver instead.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/hardware/peripherals/rtc.html#rtc-emulated-device"&gt;https://docs.zephyrproject.org/latest/hardware/peripherals/rtc.html#rtc-emulated-device&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/drivers/rtc/rtc_emul.c"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/drivers/rtc/rtc_emul.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC Time Discrepancy Issue with nRF5340</title><link>https://devzone.nordicsemi.com/thread/500861?ContentTypeID=1</link><pubDate>Tue, 03 Sep 2024 03:51:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a47038a1-fae3-4b2b-a419-6459e5059dad</guid><dc:creator>Krishnachandran_a</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;Thank you for the update. The problem is that, although we updated RTC via the mobile app (using BLE) without any problems, there was a noticeable difference in RTC after around 30 minutes of operation (slow).&lt;/p&gt;
&lt;p&gt;For your reference, the RTC init and call back code are attached. Please review and share any recommendations.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void rtc_init()
{

	const nrfx_rtc_config_t config = {
		.prescaler = NRF_RTC_FREQ_TO_PRESCALER(RTC_PRESCALAR), 
		.interrupt_priority = NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY,
		.tick_latency = NRFX_RTC_US_TO_TICKS(2000, 32768),
		.reliable = true};
		
	// Function for initializing the RTC driver instance.
	nrfx_rtc_init(&amp;amp;rtc_driver_instance_0, &amp;amp;config, rtc_callback);

	IRQ_DIRECT_CONNECT(RTC0_IRQn, 0, nrfx_rtc_0_irq_handler, 0);

	// Function for disabling the TICK event.
	nrfx_rtc_tick_disable(&amp;amp;rtc_driver_instance_0);
	
	nrfx_rtc_tick_enable(&amp;amp;rtc_driver_instance_0,true);

}

void rtc_callback(nrfx_rtc_int_type_t val)
{
	nrfx_rtc_counter_clear(&amp;amp;rtc_driver_instance_0);
	// Enable interupt
	nrfx_rtc_int_enable(&amp;amp;rtc_driver_instance_0, 131072);
	update_time(val);

    if(read_rtc_state == true &amp;amp;&amp;amp; val == 4)
    {
        read_rtc_count++;
        if(read_rtc_count &amp;gt;= 100)
        {
            read_rtc_count = 0;
            rtc_read_callback_function();
        }
    }
    else if(read_rtc_state  == false &amp;amp;&amp;amp; read_rtc_count != 0)
    {
        read_rtc_count =0;
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Krishna Chandran&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC Time Discrepancy Issue with nRF5340</title><link>https://devzone.nordicsemi.com/thread/500797?ContentTypeID=1</link><pubDate>Mon, 02 Sep 2024 13:27:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:295e1a18-92b5-41cd-b7f2-27a985a97351</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Depending on e.g. BLE connection interval, BLE connection Slave Latency, etc, there will be a bit delay from the time mobile phone sends the data, to it&amp;#39;s&amp;nbsp;received on the nRF, and you update the RTC. You could try requesting a lower connection interval when updating, and see if that improves things.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC Time Discrepancy Issue with nRF5340</title><link>https://devzone.nordicsemi.com/thread/500665?ContentTypeID=1</link><pubDate>Sun, 01 Sep 2024 09:52:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e921de0f-8a61-401a-8946-c849797be18d</guid><dc:creator>Krishnachandran_a</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/114354/rtc-time-discrepancy-issue-with-nrf5340/500591"]Could you explain a bit more on how you do this sync? [/quote]
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;Actually we are using a mobile app, using app(BLE)we are updating the time to device.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/114354/rtc-time-discrepancy-issue-with-nrf5340/500591"]How do you get the &amp;quot;&lt;span&gt;actual time&amp;quot; ?&lt;/span&gt;[/quote]
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;Actual time means the system time.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;Krishnachandran&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC Time Discrepancy Issue with nRF5340</title><link>https://devzone.nordicsemi.com/thread/500591?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2024 12:36:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21bd73ed-8e9d-497b-9216-9d48de35a2d7</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Could you explain a bit more on how you do this sync? How do you get the &amp;quot;&lt;span&gt;actual time&amp;quot; ?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>