<?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>sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11406/sleep-function-is-not-working-when-timer-rtc-is-running-in-nrf51822</link><description>nrf51822_sleep_and_timer.txt 
 Hi... I having tough time to make the sleep function to work when timer/RTC is running in the background of nRF51822. The attached text file containing my code. After comment out the start_timer() &amp;amp; start_RTC() in the setup</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 Jan 2016 12:10:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11406/sleep-function-is-not-working-when-timer-rtc-is-running-in-nrf51822" /><item><title>RE: sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/thread/43000?ContentTypeID=1</link><pubDate>Mon, 25 Jan 2016 12:10:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5db3446-fc79-4abb-9df5-b7a7eb51854b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I do not know much about ATMEL chips and how you configure it, but any processor cannot be sleeping and still be able to run its interrupt handler. Processor has to wake up to process its enabled interrupts and then run its interrupt handler.&lt;/p&gt;
&lt;p&gt;If you want that accelerometer interrupt is the only only one that wakes your system , then you need to disable RTC interrupt. I can&amp;#39;t say why the same thing worked on ATMEL.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/thread/42999?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 10:16:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecf61399-039a-4bf8-a720-37c65f30f09f</guid><dc:creator>adrianwong</dc:creator><description>&lt;p&gt;Hi Aryan, I totally understand what you trying to explain to me. I still wondering is this Nordic characteristic? Nordic cannot sleep completely and run timer/RTC on the background. Because I try it out with Atmel chip again with the code that I have, and the sleep doesn&amp;#39;t woke up by the timer/RTC interrupt. The timer able to run at the background and the system still able to sleep. Why I know is sleeping because i put printf some string on the main loop and ntg is printing out. The system will only be woke up by the accelerometer interrupt then i only can see the printf string. Kindly assist.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/thread/42998?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 08:37:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01462fe8-210b-4d04-9e33-2dcc4d56c7b2</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Adrianwong,&lt;/p&gt;
&lt;p&gt;Consider this below program&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;RTC_INT_Handler()
{
    some_logic;    
}

main()
{
  config_RTC(0.5ms);
   ...
   ...

   forever
   {
      sleep();
      Serial.println(&amp;quot;Activity&amp;quot;);
   }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With above logic, your system will go to sleep, but will wakeup and execute the RTC_INT_Handler every 0.5ms, after it wakes up it will print your &amp;quot;Activity&amp;quot; and go to sleep again because you are executing sleep in a loop.  After 0.5ms another RTC interrupt will wake the system and exectute the interrupt handler. When finished the next line &amp;quot;Activity&amp;quot; is printed again and the system will go to sleep.&lt;/p&gt;
&lt;p&gt;The amount of time the system stays in sleep depends on the number of interrupts waking the system.
IF you want to save a lot of power, then you program RTC to give interrupts less frequently, so your system can stay in sleep mode most of the time.&lt;/p&gt;
&lt;p&gt;You can for example make RTC to give an interrupt every 1 second to update your clock, considering the system wake up time is few micro seconds + executing interrupt handler for few micro seconds, then your system will be sleeping 99.9% of the time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/thread/42997?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2016 03:10:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a2892d-6825-4e12-b248-ec62414a3546</guid><dc:creator>adrianwong</dc:creator><description>&lt;p&gt;Hi Aryan, previously when I wrote my code and upload to Atmel it was fine. The system went to sleep (might not be deep sleep), and the timer do it stuff at the back (e.g. counting a timer). The sleep mode was woke up by external interrupt (interrupt from accelerometer). If timer interrupt / RTC keep waking up the system based on time setting then it doesn&amp;#39;t make sense to me. If I want to build a timer to calculate period of 60 mins at the background how should i do? If I want to use the low power RTC to blink the led for 1 seconds every hour then what should i do? kindly advice!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/thread/42996?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2016 08:21:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98778d83-2162-4b34-b1e0-773b8ef14000</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi adrianwong,&lt;/p&gt;
&lt;p&gt;Any interrupt will wake the chip. You have configured your TIMER with CC=8000, which is 0.5ms.
You also enabled interrupt when this CC is reached and also enabled short to clear it when internal timer reaches CC value&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TIMER1-&amp;gt;SHORTS = (TIMER_SHORTS_COMPARE1_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE1_CLEAR_Pos);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So your system will have atleast one interrupt every 0.5ms from TIMER1 (more interrupts if there are other modules generating interrupts)&lt;/p&gt;
&lt;p&gt;You ask&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Why sleep will wake up when the timer
is running and calling their
interrupt? Previously, I using atmel
with arduino as i able to put the
system to sleep and timer running at
the background&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You system goes to sleep, the timer is still running in the background like you expect, but the timer is waking up your system every 0.5ms. It does not matter what code you use, ATMEL or any other CPU, the idea is the same. The interrupt will wake the system up. Maybe in ATMEL solution you were not using interrupts ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/thread/42995?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2016 03:20:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:462013e4-f32a-40b0-8567-4a14b87d1542</guid><dc:creator>adrianwong</dc:creator><description>&lt;p&gt;Hi Aryan, I calling my sleep inside loop() by using function of sleepNow(), can you see it? Why sleep will wake up when the timer is running and calling their interrupt? Previously, I using atmel with arduino as i able to put the system to sleep and timer running at the background. So currently i change to nordic nrf51822 so I trying to do the same thing with it but i facing the current problem. Anyone please help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sleep function is not working when timer/RTC is running in nRF51822</title><link>https://devzone.nordicsemi.com/thread/42994?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 12:16:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b54048de-fc81-4b36-9e63-553c665f8112</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi adrianwong,&lt;/p&gt;
&lt;p&gt;I did not see the code where you calling your loop or sleep functions, but i assume you do it somewhere.&lt;/p&gt;
&lt;p&gt;You timer is programmed to generate an interrupt every 0.5ms, which is 2000/second. Which is very fast, so even if your system sleep, waking it up every 0.5ms and trying to do some interrupt handling/printing that takes some time.&lt;/p&gt;
&lt;p&gt;Your system is still going to sleep, you cannot see it because it wakes up so frequently that you cannot judge it from the print log.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>