<?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>Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29013/best-way-to-implement-system-clock-on-nrf51</link><description>Hi everybody, 
 a while ago I used the approach proposed here devzone.nordicsemi.com/.../ to keep the date and time on a NRF51822 device while using Softdevice S110 and the Timeslot advertiser-scanner ( github.com/.../nRF51-multi-role-conn-observer-advertiser</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Jan 2021 10:49:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29013/best-way-to-implement-system-clock-on-nrf51" /><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/287190?ContentTypeID=1</link><pubDate>Mon, 04 Jan 2021 10:49:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1af93ddb-d64b-4af5-b6ed-04f90181f2be</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;if you are waking of from system IDLE (WFE) then it should not reset. Maybe you are using systemoff sleep?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/286603?ContentTypeID=1</link><pubDate>Sat, 26 Dec 2020 14:06:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2dcde0a7-04fc-468d-aa88-03550ef40785</guid><dc:creator>RixtronixLAB</dc:creator><description>&lt;p&gt;I tried with timer, but after system sleep my clock is reset .....any ideas ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/286602?ContentTypeID=1</link><pubDate>Sat, 26 Dec 2020 13:39:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7af21864-7ee1-4b58-ba29-5ca105394afa</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;By correlating it with the BLE Current Time Service I assume you mean some peer device (such as an Android) that provides an app supporting the BLE Current Time Service.&lt;/p&gt;
&lt;p&gt;How do you keep track of time between power cycles?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/286575?ContentTypeID=1</link><pubDate>Thu, 24 Dec 2020 21:51:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad3b9814-5838-4a58-bc46-a5a902ac9e15</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I had no idea this was going to be so hard. Harder than writing the rest of the BTLE pulse ox device! Anyone have finished code for an nrf51822?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114787?ContentTypeID=1</link><pubDate>Sun, 14 Jan 2018 15:33:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b59d6656-0f39-4d89-bc7e-3c02632ca8bf</guid><dc:creator>puff</dc:creator><description>&lt;p&gt;how do I use it in my project (nrf51822)
I replaced the contents of my app_timer.c and app_timer.h files, but now the APP_TIMER_INIT requires four arguments, and my previous code doesn&amp;#39;t work.
is there much work to be done to start using the new app_timer.c code? is there any example or tutorial on doing this?&lt;/p&gt;
&lt;p&gt;UPD
okay, I used&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int TIMER_TICKS_PER_SECOND=32768;
int RTC_TICKS_BITS = 24;
int TIMER_PRESCALER=0;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hopefully, that library will work with nrf51. However, my code had a separate timer, which I set up using macro:
APP_TIMER_DEF(m_our_char_timer_id);
and then
app_timer_create(&amp;amp;m_our_char_timer_id, APP_TIMER_MODE_REPEATED, timer_timeout_handler);
app_timer_start(m_our_char_timer_id, OUR_CHAR_TIMER_INTERVAL, NULL);
However, there is no such a macro in your new code. Could you please share some example on how to create an app_timer using your code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114786?ContentTypeID=1</link><pubDate>Mon, 01 Jan 2018 05:40:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:020582ed-2760-4c84-960d-a3503e8e5257</guid><dc:creator>SKV</dc:creator><description>&lt;p&gt;ok i will try (y)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114788?ContentTypeID=1</link><pubDate>Sun, 31 Dec 2017 10:34:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c4a7f41-4445-457c-ae2b-b5404fdd6d3f</guid><dc:creator>Alessandro</dc:creator><description>&lt;p&gt;Yes, you can and since you have more resources you can implement it completely in hardware. I implemented it on nrf52 using sdk 12.2 and sd s132 3.1.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114785?ContentTypeID=1</link><pubDate>Sat, 30 Dec 2017 08:46:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58e104f6-338d-42f8-93ac-50b21c2e77af</guid><dc:creator>SKV</dc:creator><description>&lt;p&gt;can implement this clock in nrf52 as well for sdk11 sd132???&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114784?ContentTypeID=1</link><pubDate>Sun, 08 Jan 2017 05:20:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e66b3d8c-5f14-47b5-9174-f16e9091fba9</guid><dc:creator>Madhuri</dc:creator><description>&lt;p&gt;Hello,
Allesandro and Clem fabulous work I could implement clock.
Very good work&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114783?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 07:59:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d82c5009-ba62-4016-8198-aa0c0034e7b5</guid><dc:creator>hawk</dc:creator><description>&lt;p&gt;hi,Alessandro: if we use the way of Clem. Does it work better for your project?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114782?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 07:32:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f74647f-535f-466d-a320-593d5968c661</guid><dc:creator>hawk</dc:creator><description>&lt;p&gt;how to use the app_timer.c of &lt;a href="https://gist.github.com/clemtaylor/26da578862ffe083bf72"&gt;gist.github.com/.../26da578862ffe083bf72&lt;/a&gt;. Can i just replace two files: app_timer.c, app_timer.h; i just use sdk 5.2.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114781?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2016 12:31:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a70fddaa-b125-4a07-b289-ce8ccd9485e7</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Seeing this very late, impressive work :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114775?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2015 20:09:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:090c2028-2edd-4a01-8fbb-e72244ae9c55</guid><dc:creator>TJ</dc:creator><description>&lt;p&gt;Another approach, that keeps the RTC running without relying on any timer, or the app_timer, as well as provide a tick is to use an RTC instance compare to generate an event and when the event occurs, just add the time increment value you want. So, for example, if you want a clock that increments every second with a RTC frequency of 8Hz, set the compare block to generate an event when the counter reaches 8. In the RTC handler, increment your clock, clear the event and add 8 to the compare reg so that it goes off at 16...etc...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114780?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2015 09:16:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d0546fd-1a2b-4722-a527-3767d260f9e6</guid><dc:creator>Alessandro</dc:creator><description>&lt;p&gt;Thanks Clem, this is really good.&lt;/p&gt;
&lt;p&gt;I was wondering, how do you compute TIMER_TICKS_PER_SECOND? Do you use ROUNDED_DIV(APP_TIMER_CLOCK_FREQ, (PRESCALER + 1)) from app_util.h?&lt;/p&gt;
&lt;p&gt;If I want to compute the milliseconds can I do it like this?
millis = timestamp_t.ticks * (1000/APP_TIMER_CLOCK_FREQ);&lt;/p&gt;
&lt;p&gt;Moreover, what do you mean that you have decoupled the hardware prescaler from the API?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114773?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2015 23:01:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:732a93ee-6bec-4009-9df2-672375221b7f</guid><dc:creator>Clem Taylor</dc:creator><description>&lt;p&gt;One thing I forgot, I&amp;#39;m still using a continuously running timer to prevent app_timer from stopping the RTC. I didn&amp;#39;t want to go through the effort to figure out exactly how to get it work properly with no events pending. Luckily in my application I use an app_timer + app_sched task to ack the watchdog and that has to run continuously.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114779?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2015 22:54:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb60e7dc-e2c4-4883-b7e5-312e07054678</guid><dc:creator>Clem Taylor</dc:creator><description>&lt;p&gt;So my changes to app_timer seem to be working.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://gist.github.com/clemtaylor/26da578862ffe083bf72"&gt;gist.github.com/.../26da578862ffe083bf72&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now I just need to figure out a less horrible way of doing long term app_timer events, specifically tasks that happen hourly and daily (synced to real time). My app_timer rewrite for the nrf52 uses int64_t for the internal timestamps and will happily queue events with timeouts &amp;gt;2*24 base ticks. It really won&amp;#39;t work on the nrf51 because it makes heavy use of __builtin_clz() which is CLZ instruction on the Cortex-M4, but a pile of code on the Cortex-M0.&lt;/p&gt;
&lt;p&gt;I have it setup to decouple the hardware prescaler from the API, so I always operate on 32768Hz, but under the hood it can be lower frequency. I mostly use timestampGet(), but the other two routines might be useful in some cases.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;typedef struct
{
    int32_t seconds;       // seconds (signed for delta) 
    int32_t ticks;         // in TIMESTAMP_TICKS_PER_SECOND 
} timestamp_t;

void timestampGet(timestamp_t *ts)
{
    uint32_t overflow, ticks, s, t;

    app_timer_ticks(&amp;amp;overflow, &amp;amp;ticks);

    s = ticks / TIMER_TICKS_PER_SECOND; // becomes &amp;gt;&amp;gt; 
    t = ticks % TIMER_TICKS_PER_SECOND; // becomes &amp;amp; 

    ts-&amp;gt;seconds =
        overflow * ((1 &amp;lt;&amp;lt; RTC_TICKS_BITS) / TIMER_TICKS_PER_SECOND) + s;
    ts-&amp;gt;ticks = t * (TIMER_PRESCALER + 1); // timestamp_t.ticks always mod 32768 
}

/* getTicks32: Convert overflow count and ticks to a 32 bit value 
 *    Note: This rolls over every 36 hours, 35 minutes, 2 seconds for 32768Hz RTC. 
 *    Note: This is in RTC ticks, not timestamp_t.ticks which are always 32768Hz. 
 */
uint32_t getTicks32(void)
{
    uint32_t overflow, ticks;
    uint32_t count;
 
    app_timer_ticks(&amp;amp;overflow, &amp;amp;ticks);
   
    count = (overflow &amp;lt;&amp;lt; RTC_TICKS_BITS) + ticks;
 
    return count;
}
 
/* getTicks64: Convert overflow count and ticks to a 64 bit monotonic value 
 *    Note: This is in RTC ticks, not timestamp_t.ticks which are always 32768Hz. 
 */
int64_t getTicks64(void)
{
    uint32_t overflow, ticks;
    int64_t count;
 
    app_timer_ticks(&amp;amp;overflow, &amp;amp;ticks);
 
    count = (((int64_t) overflow) &amp;lt;&amp;lt; RTC_TICKS_BITS) + ticks;
 
    return count;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114774?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2015 16:02:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f56dcc18-f8d6-4a67-959c-edc70af41b6f</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Thanks to both of you for your ideas. I think Alessandro is right, truncating the app_timer to 1 second is a non-starter for me. It took a couple of reads, but I think I get Clem&amp;#39;s solution now. I don&amp;#39;t even need milli-second resolution, just 1 second but I can get that with a quick divide of the RTC counter register.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114772?ContentTypeID=1</link><pubDate>Sun, 18 Oct 2015 13:02:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06301106-38b0-443b-8db7-1df33076d264</guid><dc:creator>Alessandro</dc:creator><description>&lt;p&gt;Yes, this should be fine, but I had in mind a different thing.
At the link is the code I wrote to modify app_timer.c, it is a bit speculative because I cannot try it until tomorrow :)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://pastie.org/10492786"&gt;Code&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then I call ppi_init() and timer1_init() before rtc1_init(prescaler) and don&amp;#39;t clear the COMPARE[1] event in RTC1_IRQHandler.&lt;/p&gt;
&lt;p&gt;I receive the base_time from an andorid phone but I don&amp;#39;t use CTS, from the phone I advertise a packet that contains the current unix time in the manufacturer data. Probably it&amp;#39;s not the best solution but it was quick to implement :)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE 19/10/2015&lt;/strong&gt;: I have tried it on the hardware and it works fine. I had to use PPI channels 3 and 7 because these are the only available when using the SoftDevice and Timeslot advertiser-scanner library. The problem of course is that the app_timer module cannot manage timers with a period greater than 1 second because the RTC1 is cleared every second in order generate the COMPARE1 event. This means this is not a good solution because it limits the app_timer module a lot.&lt;/p&gt;
&lt;p&gt;The solution proposed by Clem is probably the best, you don&amp;#39;t need to update the CC[1] register or clear the RTC1 every second and from the number of overflows and ticks you can extract seconds and milliseconds. Of course the RCT1 cannot be stopped in this case so all the calls to rtc1_stop() should be commented.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114771?ContentTypeID=1</link><pubDate>Sun, 18 Oct 2015 10:13:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d00f8f38-e6ad-4ef4-a349-3a879a33813f</guid><dc:creator>Clem Taylor</dc:creator><description>&lt;p&gt;I implemented something along this tonight.&lt;/p&gt;
&lt;p&gt;I used TIMER1 in counter mode and PPI to trigger TASKS_COUNT from EVENTS_OVRFLW.&lt;/p&gt;
&lt;p&gt;The one thing that took be a little bit to figure out is the only way to read the counter value is to trigger a capture, not sure why TIMERn doesn&amp;#39;t have a COUNTER field like the RTC.&lt;/p&gt;
&lt;p&gt;So far it seems to work, will see how it is doing tomorrow.&lt;/p&gt;
&lt;p&gt;The one thing I&amp;#39;m not sure about is what to do with app_timer when no timers are pending. The code wants to stop the timer. Once I&amp;#39;m sure things are working with the overflow counter I&amp;#39;ll try clearing the CC interrupt.&lt;/p&gt;
&lt;p&gt;Here is my access function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void app_timer_ticks(uint32_t *p_overflow, uint32_t *p_ticks)
{
    uint32_t overflow0, overflow1, counter;
    
    APP_TIMER_OVERFLOW_COUNTER-&amp;gt;TASKS_CAPTURE[0] = 1; // trigger capture 
    overflow0 = APP_TIMER_OVERFLOW_COUNTER-&amp;gt;CC[0]; // before 
    counter   = NRF_RTC1-&amp;gt;COUNTER;
    APP_TIMER_OVERFLOW_COUNTER-&amp;gt;TASKS_CAPTURE[1] = 1; // trigger capture 
    overflow1 = APP_TIMER_OVERFLOW_COUNTER-&amp;gt;CC[1]; // after 
   
    if (overflow0 != overflow1)
    {
        /* overflow occurred (rare) 
         * we don&amp;#39;t know if overflow1 changed before or after 
         * we sampled counter1, so we just sample again 
         */
        counter = NRF_RTC1-&amp;gt;COUNTER;
    }

    *p_overflow = overflow1;
    *p_ticks    = counter;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When I fetch the time with CTS, I sample this value and that becomes my epoch offset.&lt;/p&gt;
&lt;p&gt;Now if Android bothered to implement CTS this would be so much easier.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114770?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 17:59:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd07cadc-8c60-4021-becf-c6b8500c43f0</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Hi Alessandro, that is exactly the problem I have run into with this. The app_time system is merely pushing the COMPARE[0] register out as far as it needs to to trigger the next timer(s) as I read the code. I am attempting to set the MAX_TRC_COUNTER_VAL to 0x0000FFFF so that the app_timer system uses RTC1 as a 16-bit timer rather than 24. I&amp;#39;ll let you know how that goes. Eventually I&amp;#39;d like to move to the nRF52, but RTC2 is listed as not working in the initial PAN so that has to wait for the next chip revision.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114769?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 17:19:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e57601b1-8852-485b-9e79-79af2bceb6ed</guid><dc:creator>Alessandro</dc:creator><description>&lt;p&gt;Hi John, I didn&amp;#39;t implement it yet, I might try over the weekend. I think I missed an important problem, the fact that the RTC counter will continue to count and after the first COMPARE event it will be greater than the CC register. In this situation, the next COMPARE event will be triggered only after the RTC will overflow and start again from zero.
The first idea that comes to my mind is to use the COMPARE event to trigger the COUNT on TIMER1 and the CLEAR on the RTC using PPI. This should be possible as written on the reference manual, but I don&amp;#39;t know if it is a problem for the app_timer module.&lt;/p&gt;
&lt;p&gt;It is also not very clear to me how the app_timer uses the COMPARE[0] event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114768?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 15:33:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7b5569c-7471-4a14-88f9-6580c7beedee</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Hi Alessandro, did you ever get this working? I have a very similar need. I need the app_timer subsystem, but I also want to use compare events to keep a 1 second count in the TIMER1 COUNT. The one thing I haven&amp;#39;t figured out is how to update the RTC1 CC register I need without generating a RTC1 interrupt. My prescaler is set to 0 for the RTC, so the counter will not overflow for 512 seconds. So, I either need to increment my CC register in the RTC1 interrupt which I am trying to avoid, or I guess I could change the MAX_RTC_COUNTER_VAL to 0x0000FFFF so that it only has a one second period. Any thoughts?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114767?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 08:54:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4224dc8f-95ad-44a2-baac-3461998180f0</guid><dc:creator>Alessandro</dc:creator><description>&lt;p&gt;My idea is to connect one of the RTC1 COMPARE events with the TIMER1 COUNT task using PPI. In my opinion (I am not sure it is possible) this is a just a configuration of RTC1: RTC1 will continue to produce TICK events which are used by the app_timer library but it will also produce COMPARE events (configured to happen every second) which will increment the counter on TIMER1 directly, without software intervention.
As you said before, one thing to consider is that app_timer stops the RTC1 when not needed, so, as you suggested, it is possible to remove that code or keep a timer always pending.
Another thing I noticed looking briefly at the app_timer code is that the RTC1_IRQHandler clears all the events, including the COMPARE, this probably should be removed as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114766?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 00:04:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:970a3985-b96b-4c7d-9519-ae8655a32343</guid><dc:creator>Clem Taylor</dc:creator><description>&lt;p&gt;I like the idea of mixing a RTC timer and a counter to get seconds and ticks. Especially if can be done both low power and without an interrupt. But it is not clear how you would do this while sharing the RTC with app_timer.  On the nrf52 you have an extra RTC to use, but on the nrf51 only the one RTC is available for app use and it is used by app timer.&lt;/p&gt;
&lt;p&gt;Using a spare timer to count RTC overflows seems pretty straight forward, I&amp;#39;ll have to switch over to that. The race window on incrementing my overflow count is a quite a bit bigger then I originally thought. I was only thinking of it when the timer is read from the main app and not thinking that I mostly read it from other interrupt handlers. I really wish the nrf51 had more priority levels available to to the application when using the softdevice. Luckily the nrf52 adds more priority levels which will be useful for stuff like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to implement system clock on nRF51</title><link>https://devzone.nordicsemi.com/thread/114778?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2015 19:57:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:905c77a7-381e-40f1-8270-76e69ed88b08</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I will create internal ticket to update this document. I am not sure when it will be done, but wont be ignored too long.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>