<?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 overflw handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32060/rtc-overflw-handler</link><description>Hello , I am working on the development kit nrf52, i want to know how i canget the value of the RTC overflw and then how i can reset the RTC to zero. 
 thank you in advance Best regards</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Mar 2018 14:11:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32060/rtc-overflw-handler" /><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/125024?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 14:11:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:263aa3ea-d31f-4242-853a-9f47b287ff0f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;1) enable the overflow event and interrupt&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;nrf_drv_rtc_overflow_enable&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;2)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You forgot to clear the even in RTC2 ISR, but that cannot be the reason for the system not to go to deep sleep. Also move the printf to the start of the condition.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;if(NRF_RTC2-&amp;gt;EVENTS_OVRFLW==1)&lt;br /&gt; {&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;printf(&amp;quot;overflw&amp;quot;);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NRF_RTC2-&amp;gt;EVENTS_OVRFLW = 0;&lt;/strong&gt;&lt;br /&gt; NRF_RTC2-&amp;gt;TASKS_CLEAR = 1;&lt;br /&gt; sd_power_system_off();&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is very basic thing to work. Please look at the SDK examples to see how this things work&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/125017?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 14:00:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc10fa4d-dd8f-47f2-bdb1-f396c9eac28a</guid><dc:creator>Nero</dc:creator><description>&lt;p&gt;thanks ,&lt;/p&gt;
&lt;p&gt;I initialised the RTC 2 (const nrf_drv_rtc_t rtc1 = NRF_DRV_RTC_INSTANCE(2); /**&amp;lt; Declaring an instance of nrf_drv_rtc for RTC2. */)&lt;/p&gt;
&lt;p&gt;the problem is the system does not go into sleep mode&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/125014?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 13:53:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:565dc5c9-5dcf-4112-a7c5-47165f875474</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;1) You are initializing RTC1 and checking for RTC2 events in ISR. You need to check RTC1 events in ISR.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; if(NRF_RTC2-&amp;gt;EVENTS_OVRFLW==1)
  {
		   NRF_RTC2-&amp;gt;TASKS_CLEAR		= 1;
		   sd_power_system_off();
			printf(&amp;quot;overflw&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;printf will never be executed since the sd_power_system_off will never return. Any wakeup will reset the chip. If you want to return here, then use sd_app_evt_wait() instead of system off.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124991?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 13:07:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6673778-2b7d-40a3-8cd5-4956ba447fdf</guid><dc:creator>Nero</dc:creator><description>&lt;p&gt;I initialised the rtc2 , just i use the name rtc1&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124984?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 12:49:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9981d8d-98ec-4d64-9a46-b0068d08e85d</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;rtc1 OR rtc2? &amp;nbsp;Your code seems to initialize rtc1 but looks for an event on rtc2.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124958?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 11:04:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b6fc774-99d9-4775-abf4-805ac7898a49</guid><dc:creator>Nero</dc:creator><description>&lt;p&gt;1&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124956?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 10:51:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29ca41ce-9006-46b6-a43c-48e47ae8b4ef</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;The only way you can do it is in the RTC ISR_handler. There is no shortcut in hardware to do this automatically.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124953?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 10:45:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9693d173-1d0a-471c-a3ab-6a3df0eefe8b</guid><dc:creator>Nero</dc:creator><description>&lt;p&gt;&lt;span class="" style="color:#222222;font-size:16px;position:relative;" lang="en"&gt;&lt;span class=""&gt;Thank ou Mr Aryan&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="color:#222222;font-size:16px;position:relative;" id="result_box" lang="en"&gt;&lt;span class=""&gt;there are any possibility to activate the sleep mode by an rtc overflow event?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124750?ContentTypeID=1</link><pubDate>Fri, 16 Mar 2018 11:51:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:124f59a9-21e8-4df3-b31c-381d0ea41e56</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;you need to convert the accelerometer interrupt to event by connecting it to GPIOTE in event mode&lt;/li&gt;
&lt;li&gt;Connect the output of this event to PPI and convert it to a TASK&lt;/li&gt;
&lt;li&gt;Connect this TASK to RTC-&amp;gt;TASKS_CLEAR&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This will reset the RTC counter to zero everytime you have any interrupt from accelerometer.&lt;/p&gt;
&lt;p&gt;To know more about how to configure GPIOTE and PPI for this, you need to look at their SDK examples in SDK\examples\peripheral and read the docs about them.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124725?ContentTypeID=1</link><pubDate>Fri, 16 Mar 2018 09:45:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e79e878-d8b3-466b-93d9-cc90fcde98ce</guid><dc:creator>Nero</dc:creator><description>&lt;p&gt;Hello Aryan ,&lt;/p&gt;
&lt;p&gt;Thank you for respond.&lt;/p&gt;
&lt;p&gt;I want to reset the rtc&amp;nbsp; by&amp;nbsp; a extern interruption (accelerometer), i want to know which function can i use?&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC overflw handler</title><link>https://devzone.nordicsemi.com/thread/124394?ContentTypeID=1</link><pubDate>Wed, 14 Mar 2018 14:04:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cd50f6d-f9fc-463f-8cfd-e083a28779c4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;You cannot get the overflow value but you can get an overflow event in EVENTS_OVERFLW register. For this you have to enable this event in RTC-&amp;gt;EVTEN register.&lt;/p&gt;
&lt;p&gt;You then need to enable interrupt for this in the INTENSET and increment a static variable everytime you get the overflow event. After incrementing the variable, you clear the overflow event.&lt;/p&gt;
&lt;p&gt;for example in the RTC interrupt handler you can do something like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    static uint8_t tick_overflow_count = 0;
    /* check for overflow in RTC counter */
    if(nrf_rtc_event_pending(portNRF_RTC_REG, NRF_RTC_EVENT_OVERFLOW))
    {
        nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_OVERFLOW);
        tick_overflow_count++;
    }
    
    // then you get the full value
    uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
    full_value = ((tick_overflow_count &amp;lt;&amp;lt; portNRF_RTC_BITWIDTH) + systick_counter);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>