<?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>ds3231 RTC changes the internal clock frequency in nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87141/ds3231-rtc-changes-the-internal-clock-frequency-in-nrf52840</link><description>Hello, 
 I want to compare the RTC&amp;#39;s counter_get_value() ticks with the internal clocks k_uptime_ticks() ticks. The problem is when the RTC is connected with our nrf 52840 through I2C it changes the internal clocks frequency, Im not syncronizing the clocks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Apr 2022 12:53:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87141/ds3231-rtc-changes-the-internal-clock-frequency-in-nrf52840" /><item><title>RE: ds3231 RTC changes the internal clock frequency in nrf52840</title><link>https://devzone.nordicsemi.com/thread/364231?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 12:53:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ffd6874-84db-4d20-a1f0-bec488b1eb7a</guid><dc:creator>Osse</dc:creator><description>&lt;p&gt;CONFIG_SYS_CLOCK_TICKS_PER_SEC&amp;nbsp; is set to 32768 in autoconfig.h&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ds3231 RTC changes the internal clock frequency in nrf52840</title><link>https://devzone.nordicsemi.com/thread/364165?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 09:50:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1aa8b1a-bb2c-41a6-a39b-d47421f285af</guid><dc:creator>qwertynoon</dc:creator><description>&lt;p&gt;You have to know how much tics do you have at 1 second&lt;/p&gt;
&lt;p&gt;This value should be your reference&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;LOG_INF(&amp;quot;CONFIG_SYS_CLOCK_TICKS_PER_SEC = %d&amp;quot;, CONFIG_SYS_CLOCK_TICKS_PER_SEC);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ds3231 RTC changes the internal clock frequency in nrf52840</title><link>https://devzone.nordicsemi.com/thread/364131?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 08:22:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5aef156e-7a10-4100-88c6-63eb9ede60ac</guid><dc:creator>Osse</dc:creator><description>&lt;p&gt;We get this same issue with the sampe &amp;quot;Maxim DS3231 TCXO RTC Sample Application&amp;quot;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/samples/drivers/counter/maxim_ds3231/README.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/samples/drivers/counter/maxim_ds3231/README.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We modified the function set_aligned_clock a bit, to write to the terminal before and after the call on &amp;quot;k_sleep(K_msec(10000));&amp;quot;. We print t2 - t1, this seems correct, 327690 ticks, but measuring with a stop watch it took 95 seconds. Almost 10 times 10 000msec. Mind you this is the only change we made to the sample. We use the same overlay file.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The changes to the function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void set_aligned_clock(const struct device *ds3231)
{
	if (!IS_ENABLED(CONFIG_APP_SET_ALIGNED_CLOCK)) {
		return;
	}

	uint32_t syncclock_Hz = maxim_ds3231_syncclock_frequency(ds3231);
	uint32_t syncclock = maxim_ds3231_read_syncclock(ds3231);
	uint32_t now = 0;
	int rc = counter_get_value(ds3231, &amp;amp;now);
	uint32_t align_hour = now + 3600 - (now % 3600);

	struct maxim_ds3231_syncpoint sp = {
		.rtc = {
			.tv_sec = align_hour,
			.tv_nsec = (uint64_t)NSEC_PER_SEC * syncclock / syncclock_Hz,
		},
		.syncclock = syncclock,
	};

	struct k_poll_signal ss;
	struct sys_notify notify;
	struct k_poll_event sevt = K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
							    K_POLL_MODE_NOTIFY_ONLY,
							    &amp;amp;ss);

	k_poll_signal_init(&amp;amp;ss);
	sys_notify_init_signal(&amp;amp;notify, &amp;amp;ss);

	uint32_t t0 = k_uptime_get_32();

	rc = maxim_ds3231_set(ds3231, &amp;amp;sp, &amp;amp;notify);

	printk(&amp;quot;\nSet %s at %u ms past: %d\n&amp;quot;, format_time(sp.rtc.tv_sec, sp.rtc.tv_nsec),
	       syncclock, rc);

	/* Wait for the set to complete */
	rc = k_poll(&amp;amp;sevt, 1, K_FOREVER);

	uint32_t t1 = k_uptime_ticks();
	printk(&amp;quot;begins the timer&amp;quot;);

	/* Delay so log messages from sync can complete */
	k_sleep(K_MSEC(10000));
	printk(&amp;quot;stops the timer&amp;quot;);
	uint32_t t2 = k_uptime_ticks();

	printk(&amp;quot;Synchronize final: %d %d in %u ms\n&amp;quot;, rc, ss.result, t2 - t1);

	rc = maxim_ds3231_get_syncpoint(ds3231, &amp;amp;sp);
	printk(&amp;quot;wrote sync %d: %u %u at %u\n&amp;quot;, rc,
	       (uint32_t)sp.rtc.tv_sec, (uint32_t)sp.rtc.tv_nsec,
	       sp.syncclock);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Our deck:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/IMG_5F00_4934.jpg" /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/IMG_5F00_4935.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ds3231 RTC changes the internal clock frequency in nrf52840</title><link>https://devzone.nordicsemi.com/thread/364026?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 16:48:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53f630a3-beae-4f71-a44c-2590a7649b00</guid><dc:creator>qwertynoon</dc:creator><description>&lt;p&gt;Could you please explain your issue with detail.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>