<?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>Can Softdevice RTC be used without an interrupt handler?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44760/can-softdevice-rtc-be-used-without-an-interrupt-handler</link><description>I want to run the realtime counter RTC2 with softdevice S132 WITHOUT an interrupt handler. I have no purpose for an RTC2 interrupt handler in my code, as I simply want to poll the hardware based RTC2 counter. Also, since the RTC2 clock will be set at</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 20 Aug 2020 10:38:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44760/can-softdevice-rtc-be-used-without-an-interrupt-handler" /><item><title>RE: Can Softdevice RTC be used without an interrupt handler?</title><link>https://devzone.nordicsemi.com/thread/265510?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 10:38:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f78ba50-b79d-443e-96ef-32cb2a854840</guid><dc:creator>kjhuebner</dc:creator><description>&lt;p&gt;If my memory serves me right -- I confirmed the RTC2 clock rate by creating a program loop that polls the RTC2 clock value and toggling an IO pin.&amp;nbsp; Then while the Nordic device is running, observing the IO pin using an oscilloscope. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;The pseudo code looks like this...&lt;/p&gt;
&lt;p&gt;unsigned int read_value;&lt;/p&gt;
&lt;p&gt;while(true)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp; read_value= RTC2 clock value ;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; while (read_value == RTC2 clock value)&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; set IO pin = high&lt;/p&gt;
&lt;p&gt;&amp;nbsp; read_value= RTC2 clock value ;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; while (read_value == RTC2 clock value)&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; set IO pin = low&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Keep in mind for the above code...&amp;nbsp; your logic analyzer will show a&lt;/p&gt;
&lt;p&gt;frequency rate= desired RTC2 clock rate divided by 2.&lt;/p&gt;
&lt;p&gt;The reason is the above code has a toggle high and a toggle low for each full wave of output signal.&amp;nbsp; I think you get the picture.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;ALTERNATIVE SOLUTION:&lt;/p&gt;
&lt;p&gt;One could read RTC2 clock into &amp;quot;read_value&amp;quot;, then add 1000 to read_value, then poll the RTC2 clock until it reaches the value, then toggle IO pin.&amp;nbsp; This would avoid the possibility of missing clock ticks if your RTC2 clock rate is exceptionally high.&amp;nbsp; Of course in this case, your oscilloscope or logic analyzer will show a&lt;/p&gt;
&lt;p&gt;frequency rate= desired RTC2 clock rate divided by 2000.&lt;/p&gt;
&lt;p&gt;-Ken&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&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: Can Softdevice RTC be used without an interrupt handler?</title><link>https://devzone.nordicsemi.com/thread/265463?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 07:33:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82bd61b2-6937-47a2-a546-a2f6ace2e0ae</guid><dc:creator>Zoran</dc:creator><description>&lt;p&gt;Hi Ken,&lt;br /&gt;i just implemented your solution and it works well. Thanks for providing this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I want to confirm my RTC 2 clock rate with my logic analyzer. How did you do this without a handler?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can Softdevice RTC be used without an interrupt handler?</title><link>https://devzone.nordicsemi.com/thread/176052?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 20:28:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d450d90-7a18-4f0c-a7b4-1e7d6c602528</guid><dc:creator>kjhuebner</dc:creator><description>&lt;p&gt;&lt;strong&gt;Kenneth - Your solution #4 seems best.&amp;nbsp; If I have time, I may go with it instead. &amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;One day...&amp;nbsp; maybe Nordic will provide &lt;span style="text-decoration:underline;"&gt;a proper solution&lt;/span&gt; and allow developers to use RTC clocks without handlers.&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can Softdevice RTC be used without an interrupt handler?</title><link>https://devzone.nordicsemi.com/thread/176050?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 20:17:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:374db0d0-0fda-49a6-bdad-f1d65d964213</guid><dc:creator>kjhuebner</dc:creator><description>&lt;p&gt;&lt;strong&gt;Forgot one item: place this at top of source file.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;const nrf_drv_rtc_t m_rtc = NRF_DRV_RTC_INSTANCE(2);&amp;nbsp; /**&amp;lt; Declaring an instance of nrf_drv_rtc for RTC2. */&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can Softdevice RTC be used without an interrupt handler?</title><link>https://devzone.nordicsemi.com/thread/176048?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 20:08:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e90c3815-1497-443a-8fbe-4df3738131c5</guid><dc:creator>kjhuebner</dc:creator><description>&lt;p&gt;&lt;strong&gt;Hi,&amp;nbsp; Thanks for your notes.&amp;nbsp; My solution to avoid using an RTC handler was to call Nordic&amp;#39;s &amp;quot;Softdevice 132&amp;quot; low level functions.&amp;nbsp; The following compiles and runs fine, with a confirmed 8192 hz RTC clock rate.&amp;nbsp; No handler required.&amp;nbsp; The one caveat is I&amp;#39;m not sure how stable and long lasting the API will be, recognizing these are low level functions.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;-Ken&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SOLUTION:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Set RTC config to default.&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_drv_rtc_config_t rtc_config = NRF_DRV_RTC_DEFAULT_CONFIG;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;#define APP_RTC_CLOCK_FREQ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8192&amp;nbsp;&amp;nbsp;&amp;nbsp; //hz&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rtc_config.prescaler = 3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //resulting freq= 8192 hz.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRFX_IRQ_PRIORITY_SET(m_rtc.irq, rtc_config.interrupt_priority);&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRFX_IRQ_ENABLE(m_rtc.irq);&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_rtc_prescaler_set(m_rtc.p_reg, rtc_config.prescaler);&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Enable Nordic RTC. &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_rtc_task_trigger(m_rtc.p_reg, NRF_RTC_TASK_START);&amp;nbsp;&amp;nbsp;&amp;nbsp; //RUNTIME RTC2 WORKS OK!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can Softdevice RTC be used without an interrupt handler?</title><link>https://devzone.nordicsemi.com/thread/176041?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 19:05:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:510daf39-ec22-41d2-966a-03c4a84ad09f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see your point, but I don&amp;#39;t have any good workarounds here other than to suggest a few more possibilities:&lt;/p&gt;
&lt;p&gt;3. the rtc interrupt may be set to occur very infrequent, in other words every ~30minutes, I doubt that will be measurable on average current.&lt;/p&gt;
&lt;p&gt;4. you may just disable the interrupt manually after starting the clock by the driver by calling NRF_RTC1-&amp;gt;INTENCLR (a hack I know)&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>