<?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>[TIMER] Receive another message when a timer is active.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65493/timer-receive-another-message-when-a-timer-is-active</link><description>Hi, I&amp;#39;m HongJae. 
 I&amp;#39;m developing a Bluetooth peripheral program with nrf52. 
 
 Briefly, 
 if I send a hexadecimal message(e.g 0x35), GPIO&amp;#39;s are ON. 
 After 1 minute from getting the message, GPIO&amp;#39;s are OFF. 
 
 To count 1 minute, I&amp;#39;ve used &amp;quot;nrf_delay_ms</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 02 Sep 2020 12:54:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65493/timer-receive-another-message-when-a-timer-is-active" /><item><title>RE: [TIMER] Receive another message when a timer is active.</title><link>https://devzone.nordicsemi.com/thread/267632?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 12:54:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea9a4d7b-c3c8-4d4b-995b-068e8218feae</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]To count 1 minute, I&amp;#39;ve used &amp;quot;nrf_delay_ms&amp;quot; function.[/quote]
&lt;p&gt;&amp;nbsp;[quote user=""][/quote]&lt;/p&gt;
&lt;p&gt;Could you let me know that&amp;nbsp;&lt;/p&gt;
&lt;p&gt;how to receive messages when a timer is active?&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think there might be a misunderstanding here. nrf_delay_ms is not a timer in the normal microcontroller sense. nrf_delay_ms is just wasted NOP CPU cycles, that approximately will take a certain number of ms to complete. Due to this, the CPU is actually in use / active for the entire time of the nrf_delay_ms, it is just that its computations are worthless.&lt;br /&gt;&lt;br /&gt;What you instead would like to do is use the TIMER peripheral, so that you do not have to use active CPU time to measure the passing of time.&lt;br /&gt;You can read more about the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Ftimer.html&amp;amp;anchor=concept_xbd_hqp_sr"&gt;TIMER peripheral in its documentation&lt;/a&gt;. I would also highly recommend that you take a look at the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/nrf_dev_timer_example.html"&gt;TIMER example from the SDK&lt;/a&gt;. The TIMER example demonstrates how you could set up a TIMER to trigger every 500 ms, and have that event toggle a LED.&lt;br /&gt;Using a TIMER instead of nrf_delay_ms will free up your CPU to do other things while waiting for the time to pass.&lt;br /&gt;&lt;br /&gt;Please also keep in mind that the SoftDevice takes priority over any application layer code, so that the Bluetooth Low-Energy connection is maintained, regardless of what your application code is doing. This means that the SoftDevice will take control over the CPU every so often which is needed to fulfill the BLE requirements.&lt;br /&gt;&lt;br /&gt;I am not sure I have understood all that you are asking about in your ticket - in the case that I have not, please let me know what I might have missed, or if anything still should be unclear!&lt;br /&gt;&lt;br /&gt;For the record, when sharing code please use the &amp;quot; Insert - &amp;gt; Code &amp;quot; option as it drastically increases the readability of your code you have shared.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>