<?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>How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/43119/how-to-add-clock-function-to-ble_app_uart-sdk12-with-nrf51dk</link><description>I need to add a clock function to the ble_app_uart example (SDK12). Where can I find a hint on how to do it? Do I need an external 32768Hz quartz? I wanted to derive from the 16 MHz quartz instead to save cost.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 31 Jan 2019 09:25:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/43119/how-to-add-clock-function-to-ble_app_uart-sdk12-with-nrf51dk" /><item><title>RE: How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/thread/168817?ContentTypeID=1</link><pubDate>Thu, 31 Jan 2019 09:25:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf78a3ad-4584-4595-871e-da5bd8882b2c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Good to hear that you found the cause of the issue!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/thread/168748?ContentTypeID=1</link><pubDate>Wed, 30 Jan 2019 15:04:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd84cc43-e5e3-4297-b67b-51b90aec14de</guid><dc:creator>Sergio T</dc:creator><description>&lt;p&gt;Sorry, I found the problem: I had to add&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NVIC_SetPriority(TIMER1_IRQn, 3);&lt;br /&gt; NVIC_EnableIRQ(TIMER1_IRQn);&lt;/p&gt;
&lt;p&gt;before starting TIMER1. Now I get TIMER1 interrupts.&lt;/p&gt;
&lt;p&gt;Thanks for the help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/thread/168735?ContentTypeID=1</link><pubDate>Wed, 30 Jan 2019 14:35:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7153e49a-8301-40f1-9e2c-a78cfb3f8ddc</guid><dc:creator>Sergio T</dc:creator><description>&lt;p&gt;Also, I tried putting TIMER1 to work with the code below but I don&amp;#39;t succeed to get any interrupt. What is wrong?&lt;/p&gt;
&lt;p&gt;I am using ble_app_uart example from SDK12.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  NRF_TIMER1-&amp;gt;TASKS_STOP = 1;
  NRF_TIMER1-&amp;gt;TASKS_CLEAR = 1;
  NRF_TIMER1-&amp;gt;PRESCALER = 4; 
  NRF_TIMER1-&amp;gt;CC[0] = 1000000;                           //  1 second
  NRF_TIMER1-&amp;gt;MODE = TIMER_MODE_MODE_Timer; 
  NRF_TIMER1-&amp;gt;BITMODE = TIMER_BITMODE_BITMODE_16Bit; 
  NRF_TIMER1-&amp;gt;INTENSET = TIMER_INTENSET_COMPARE0_Enabled &amp;lt;&amp;lt; TIMER_INTENSET_COMPARE0_Pos;
  NRF_TIMER1-&amp;gt;SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE0_CLEAR_Pos);		
  NRF_TIMER1-&amp;gt;TASKS_START = 1;*/
&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/thread/168656?ContentTypeID=1</link><pubDate>Wed, 30 Jan 2019 10:21:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba2d45f2-5ff0-4f3d-8d0d-0c8b20d892e4</guid><dc:creator>Edvin</dc:creator><description>[quote user="Sergio T"]I wanted to use the synthesized clock so I think all I need to do is set the source to NRF_CLOCK_SRC_SYNTH.[/quote]
&lt;p&gt;&amp;nbsp;Yes. You can do this, but be aware that this draws a bit more current, but it is also more accurate than the RC oscillator.&lt;/p&gt;
[quote user="Sergio T"]The next question is where can I find information about the clock function? I need to know how I can count the time and date, including daylight saving and so on.[/quote]
&lt;p&gt;&amp;nbsp;Well. We don&amp;#39;t have a library for this. The app_timer is probably the way you want to go here. You can absolutely base your application on the ble_app_uart example. Just look at e.g. the ble_app_hrs example on how to set up the app_timer for your application. This example uses it to update the simulated battery level.&lt;/p&gt;
&lt;p&gt;I believe that to keep track of time, you would need a timer that times out every second, 10 seconds, minute, hour, or whatever time resolution you need. Then use this timer to increment&amp;nbsp;your&amp;nbsp;&amp;quot;current time&amp;quot; variable.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To get the current time, you can look into the &amp;quot;current time service&amp;quot; which is used in the ble_app_cts_c example (&lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/ble_sdk_app_cts_c"&gt;description here&lt;/a&gt;). This service will give you the current time from the device that is connected, e.g. a phone, in order to synchronize the current time and date.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT:&lt;/p&gt;
&lt;p&gt;The link to the description of the ble_app_cts_c example as nRF51 is not supported in SDK15. Use this link instead:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v12-3-0/ble_sdk_app_cts_c"&gt;https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v12-3-0/ble_sdk_app_cts_c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/thread/168525?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 15:34:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1288e27a-7c07-4576-a9cc-456384f32b4d</guid><dc:creator>Sergio T</dc:creator><description>&lt;p&gt;To make it a bit more clear, I am using the ble_app_uart example from SDK12 to start building my application. According to what I read, RTC0 and RTC1 are already used and nRF51DK doesn&amp;#39;t have RTC2. This means I have to implement my watch (clock and date) on a Timer. Is this right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/thread/168510?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 14:57:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f81d61e2-9c11-4240-a0ee-0cbf25c30a66</guid><dc:creator>Sergio T</dc:creator><description>&lt;p&gt;Thanks Edvin.&lt;/p&gt;
&lt;p&gt;I need&amp;nbsp;a Date and Clock with some accuracy for my application because I have to run a schedule according to the user needs. This schedule is set via Bluetooth and it may take several months until the user sets a different schedule again, so the clock has to be close to exact.&lt;/p&gt;
&lt;p&gt;I wanted to use the synthesized clock so I think all I need to do is set the source to NRF_CLOCK_SRC_SYNTH.&lt;/p&gt;
&lt;p&gt;The next question is where can I find information about the clock function? I need to know how I can count the time and date, including daylight saving and so on.&lt;/p&gt;
&lt;p&gt;Sorry but I always made the complete program in all my applications so I am not used to using code already made by someone else.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add clock function to ble_app_uart? (SDK12 with nRF51DK)</title><link>https://devzone.nordicsemi.com/thread/168472?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 13:37:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f19014f1-8dcb-4765-b410-40df73c77189</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;What sort of clock function are you looking for?&lt;/p&gt;
&lt;p&gt;You don&amp;#39;t need an external 32768Hz XTAL. You can use the&amp;nbsp;RC Oscillator.&lt;/p&gt;
&lt;p&gt;Please be aware that using the RC Oscillator is less accurate, and draws a bit more power than having an external LFXTAL.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To change to the RC Oscillatorin SDK12, look for the define&amp;nbsp;NRF_CLOCK_LFCLKSRC (in pca10028.h, or your custom board file if you have a custom PCB).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To see what the different parameters mean, check out nrf_sdm.h line 204 - 235. To get started using the RC Oscillator you can set NRF_CLOCK_LFCLKSRC to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Low frequency clock source to be used by the SoftDevice
#define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_RC,            \
                                 .rc_ctiv       = 16,                                \
                                 .rc_temp_ctiv  = 2,                                \
                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_500_PPM}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>