<?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>I want to keep running RTC even when nrf51 is in sleep mode,is there any way ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20381/i-want-to-keep-running-rtc-even-when-nrf51-is-in-sleep-mode-is-there-any-way</link><description>I am running RTC in nrf51, after coming out of sleep mode RTC is getting reset.I want this RTC to keep running so that we can use it as wake up signal.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Mar 2017 18:54:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20381/i-want-to-keep-running-rtc-even-when-nrf51-is-in-sleep-mode-is-there-any-way" /><item><title>RE: I want to keep running RTC even when nrf51 is in sleep mode,is there any way ?</title><link>https://devzone.nordicsemi.com/thread/79452?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2017 18:54:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67ff246f-4ee8-40eb-b351-c2690ff43993</guid><dc:creator>David</dc:creator><description>&lt;p&gt;You don&amp;#39;t have to configure anything. Just use one of the two sleep functions from my post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to keep running RTC even when nrf51 is in sleep mode,is there any way ?</title><link>https://devzone.nordicsemi.com/thread/79451?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2017 17:27:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12dcaedb-294f-4cf7-8cbf-05358cb02779</guid><dc:creator>Pranay</dc:creator><description>&lt;p&gt;how can we configure system on mode?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to keep running RTC even when nrf51 is in sleep mode,is there any way ?</title><link>https://devzone.nordicsemi.com/thread/79450?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2017 17:21:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3d3ea73-51a3-42f6-83a3-3c100327038e</guid><dc:creator>David</dc:creator><description>&lt;p&gt;The RTC peripheral will continue to run as normal if you use System On sleep.&lt;/p&gt;
&lt;p&gt;The following code works for me as a 30 second wakeup timer.&lt;/p&gt;
&lt;p&gt;Initialize Timer:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_RTC0-&amp;gt;TASKS_STOP = 1;							// Stop if running for whatever reason
nrf_delay_us(75);									// We have to wait at least 1 LFCLK tick for stop to take effect.

NRF_RTC0-&amp;gt;PRESCALER = 32;							// ~1ms
NRF_RTC0-&amp;gt;CC[0] = 29789;							// 30.0 seconds
NRF_RTC0-&amp;gt;INTENSET = RTC_INTENSET_COMPARE0_Msk;
NRF_RTC0-&amp;gt;TASKS_CLEAR = 1;
NRF_RTC0-&amp;gt;TASKS_START = 1;							// Start timer immediately.

NVIC_EnableIRQ(RTC0_IRQn);							// Enable IRQ
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sleep (if SD Disabled):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Wait for interrupt (System ON sleep)
__WFI();   
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sleep (if SD Enabled)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sd_app_evt_wait();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you need the interrupt handler for RTC0&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void RTC0_IRQHandler(void)
{
	if ((NRF_RTC0-&amp;gt;EVENTS_COMPARE[0] != 0) &amp;amp;&amp;amp;
        ((NRF_RTC0-&amp;gt;INTENSET &amp;amp; RTC_INTENSET_COMPARE0_Msk) != 0))
    {
		// Do stuff here

		
		// Clear CC flag
		NRF_RTC0-&amp;gt;EVENTS_COMPARE[0] = 0;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>