<?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>Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53902/clarification-about-nrf-calaendar-example</link><description>Hello, 
 I&amp;#39;m trying to integrate the nrf Calendar example here with Current Time Service client implementation on a nRF52840 DK. 
 I&amp;#39;m trying to understand the logic of the Calendar example. 
 Can someone explain the nrf_cal_set_callback function in nrf_calendar</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Aug 2020 08:57:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53902/clarification-about-nrf-calaendar-example" /><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/266913?ContentTypeID=1</link><pubDate>Fri, 28 Aug 2020 08:57:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1d492d6-e9fb-4fc7-8c29-94ca953e8931</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
[quote user="nordev"]Why? What are the downsides to doing so?[/quote]
&lt;p&gt;There are no downsides per se, but the idea of the library is for it to keep track of time for you, not the other way around ;)&lt;/p&gt;
&lt;p&gt;Say you use a 20PPM external 32k crystal, then the worst case time drift is 1.7 seconds pr day. If you correct the time from some external source (like a smart phone)&amp;nbsp;every day you should only be off by a second or two at the most, and depending on how accurate time you need you might be able to set it even more rarely, like every week or two.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user="nordev"]Hypothetically, is&amp;nbsp;it reasonable to call the set_time() function&amp;nbsp;each time the BLE device connects with the central (phone)?[/quote]
&lt;p&gt;I would say it depends on how often you expect the customer to connect to the phone. If this happens &amp;#39;once in a while&amp;#39; then I agree it makes sense to set the time on every connection, as you might not know how long time it will be until the next time the user connects the app.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/266673?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 09:24:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95a43851-7b29-47db-9fcd-0aaf807c178d</guid><dc:creator>nordev</dc:creator><description>[quote userid="2116" url="~/f/nordic-q-a/53902/clarification-about-nrf-calaendar-example/266422"]it is not meant to be run repeatedly as a part of normal operation[/quote]
&lt;p&gt;Why? What are the downsides to doing so?&lt;/p&gt;
&lt;p&gt;Hypothetically, is&amp;nbsp;it reasonable to call the set_time() function&amp;nbsp;each time the BLE device connects with the central (phone)? This might be at &lt;em&gt;most&lt;/em&gt; 1x/h, but under normal operation, the user would connect and stay connected.&amp;nbsp;I can plan to have a timeout as well&amp;nbsp;to correct for the deviation due to the internal oscillator in case the user stays connected too long.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/266422?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 09:36:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bbbb80d-30d4-49de-9d16-1a0c32fd5812</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;This line makes sure that the time is updated once RTC is cleared, yes, to make sure that you can keep track of time over a longer period.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Without this line you would not be able to keep track of time over minutes, hours and days, unless you used a very high increment value.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;&lt;span&gt;nrf_cal_set_time() function is intended to be used by the application whenever you want to&amp;nbsp;change the time in the nRF52, it is not meant to be run repeatedly as a part of normal operation.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/266358?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 06:37:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dbf7e45-0889-4f8b-8413-28f8c6ac649f</guid><dc:creator>nordev</dc:creator><description>&lt;p&gt;I have another clarification question about this example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is the purpose of the second to last line here: &lt;br /&gt;(&lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.c#L110"&gt;https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.c#L110&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void CAL_RTC_IRQHandler(void)
{
    if(CAL_RTC-&amp;gt;EVENTS_COMPARE[0])
    {
        CAL_RTC-&amp;gt;EVENTS_COMPARE[0] = 0;
        
        CAL_RTC-&amp;gt;TASKS_CLEAR = 1;
        
        m_time += m_rtc_increment;
        if(cal_event_callback) cal_event_callback();
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Are you trying to keep time updated by updating m_time every time the RTC runs out (which happens every m_rtc_increment seconds, in this case 1m), instead of calling nrf_cal_set_time() the next time you want m_time to be updated? Why don&amp;#39;t you just call nrf_cal_set_time() if you want to update m_time? It seems like you would only do it once a minute here-- or do you consider that &amp;quot;too often,&amp;quot; and if so, why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/219007?ContentTypeID=1</link><pubDate>Thu, 07 Nov 2019 10:04:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82e5b9c2-2a42-4975-8e10-13b0389a4e71</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;It is a simple linear correction&amp;nbsp;that is intended to detect if the internal clock is running consistently too slow or too fast.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you adjust the time in the calender library it will detect if the internal clock ran faster or slower than the &amp;#39;real&amp;#39; time provided through the&amp;nbsp;&lt;span&gt;nrf_cal_set_time(..) function, compared to the last time&amp;nbsp;nrf_cal_set_time(..) was called.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For this to work properly it assumes that clock inaccuracies are consistent (don&amp;#39;t vary over time), that you don&amp;#39;t call&amp;nbsp;nrf_cal_set_time(..) very often, and that you don&amp;#39;t call&amp;nbsp;nrf_cal_set_time(..) with an outdated time stamp.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It&amp;#39;s worth mentioning that this function hasn&amp;#39;t been tested very extensively either, so please use it at your own risk ;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you need good clock accuracy&amp;nbsp;I would strongly recommend using an external LF crystal rather than relying on the calibration.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/218891?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 15:50:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba719679-f7d0-4246-8a09-9f66c3d5273d</guid><dc:creator>RO</dc:creator><description>&lt;p&gt;Can I get a clarification about the calibration logic :&amp;nbsp;&lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.c"&gt;&lt;span class="pl-en"&gt;nrf_cal_get_time_calibrated&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class="pl-k"&gt;void&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.c"&gt;)&amp;nbsp;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/218253?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2019 14:01:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c45b41c-21a4-4bb7-8adb-6bc0888d0def</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, this is exactly how I implemented it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you take a look at &lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.c#L111"&gt;this line&lt;/a&gt; in nrf_calendar.c you will see that I trigger the callback in the RTC compare event.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/217987?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2019 14:17:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b10bbbb3-38df-4468-ad02-858a3d503fc6</guid><dc:creator>RO</dc:creator><description>&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m trying to convert the code to using the RTC driver.&lt;/p&gt;
&lt;p&gt;So I can replace the callback function with an RTC COMPARE event?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification about nrf-calaendar example</title><link>https://devzone.nordicsemi.com/thread/217976?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2019 13:29:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b7a74f9-cc13-46db-b2dc-f84579c6950b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;All it does is allow you to get a callback at regular intervals, what to do in the callback is entirely up to you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s convenient if you want to do something with the time information at a regular rate (such as display it somewhere, or store it to flash), but you could also use the app_timer library for the same purpose.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>