<?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>NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90377/ncs-conflict-between-timer-interrupt-and-ble-stack</link><description>Hi, 
 I want to use timer interrupt in BLE code. If enable timer inside the BLE code. The code will not work properly. I want to know why this is happening like that and how can I implement the timer interrupt inside the BLE code. I am using nrf5340dk</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 20 Aug 2022 02:05:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90377/ncs-conflict-between-timer-interrupt-and-ble-stack" /><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/382511?ContentTypeID=1</link><pubDate>Sat, 20 Aug 2022 02:05:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8115cb7b-641b-47ad-8293-b61a90449167</guid><dc:creator>Mr.NCK</dc:creator><description>&lt;p&gt;Hi Helsing,&lt;/p&gt;
&lt;p&gt;Thank you so much, i will check and you know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/382279?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2022 12:41:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ba651cf-8fd7-468f-919b-c34e65c70733</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hi Navin,&lt;/p&gt;
&lt;p&gt;Here are two possible solutions:&lt;/p&gt;
&lt;p&gt;Solution A, to run the sampling from a separate thread using a delay in the similar way to what you do currently. Delays in Zephyr are not implemented as busy waits. They allow other threads to run concurrently.&lt;/p&gt;
&lt;p&gt;Solution B:&amp;nbsp; Use a zephyr timer that triggers a work item. Consult the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/kernel/timing/timers.html"&gt;documentation for Timers&lt;/a&gt;, specifically check out &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/kernel/timing/timers.html#using-a-timer-expiry-function"&gt;Using a Timer Expiry Function&lt;/a&gt;:&lt;/p&gt;
&lt;div&gt;
&lt;p&gt;The following code uses a timer to perform a non-trivial action on a periodic basis. Since the required work cannot be done at interrupt level, the timer’s expiry function submits a work item to the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/kernel/threads/workqueue.html#workqueues-v2"&gt;&lt;span&gt;system workqueue&lt;/span&gt;&lt;/a&gt;, whose thread performs the work.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void my_work_handler(struct k_work *work)
{
    /* do the processing that needs to be done periodically */
    ...
}

K_WORK_DEFINE(my_work, my_work_handler);

void my_timer_handler(struct k_timer *dummy)
{
    k_work_submit(&amp;amp;my_work);
}

K_TIMER_DEFINE(my_timer, my_timer_handler, NULL);

...

/* start periodic timer that expires once every second */
k_timer_start(&amp;amp;my_timer, K_SECONDS(1), K_SECONDS(1));&lt;/pre&gt;&lt;/pre&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/382082?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 14:15:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5704de06-7986-4154-9f82-76410d856f94</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hi Navin,&lt;/p&gt;
&lt;p&gt;Sorry for the delay. &lt;/p&gt;
&lt;p&gt;I noticed I had given you the wrong link for the Work Item. Have you considered this solution?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/381315?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2022 09:21:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29aef9c4-109e-43a3-b353-b894312878d2</guid><dc:creator>Mr.NCK</dc:creator><description>&lt;p&gt;HI Helsing,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I follow those points and once, I have called the timer in the thread function it starts working.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Instead of delay. I want to use this timer function. Can you able to help me?. Kindly share me example if anything is available&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards,&lt;/p&gt;
&lt;p&gt;Navin&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/381312?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2022 09:18:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6980081-92f8-4634-886f-f98e4c7c0f60</guid><dc:creator>Mr.NCK</dc:creator><description>&lt;p&gt;HI Helsing,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I follow those points and once, I have called the timer in the thread function it starts working.&lt;/p&gt;
&lt;p&gt;Thanks and Regards,&lt;/p&gt;
&lt;p&gt;Navin&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/381179?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2022 11:34:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aaf76101-aeba-4716-9719-f5f10fa55ffb</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hi Navin,&lt;/p&gt;
&lt;p&gt;Sorry, I did not notice you had posted a reply as your case has been marked as &amp;quot;Verified answer&amp;quot;. Is your case solved, or would you like me to have a look at your code?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/379714?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 12:28:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00cb833e-9ded-4dff-89bf-365865ab9a03</guid><dc:creator>Mr.NCK</dc:creator><description>&lt;p&gt;Hi Helsing,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I have attached the code below Kindly check and let me the corrections.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ADXL_5F00_BLE_5F00_Timer.zip"&gt;devzone.nordicsemi.com/.../ADXL_5F00_BLE_5F00_Timer.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards&lt;/p&gt;
&lt;p&gt;Navin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/379594?ContentTypeID=1</link><pubDate>Mon, 01 Aug 2022 17:57:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2dd281e-a8da-4cf5-9cdf-e0d93bb12c7b</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hi Navin, sorry for the delay.&lt;/p&gt;
&lt;p&gt;Would you be able to share your code?&lt;/p&gt;
&lt;p&gt;Are you calling any &amp;#39;k_timer&amp;#39; functions from any interrupt context, or from inside a callback? If so, then one solution is to use a &lt;em&gt;work item&lt;/em&gt; instead. Submit the work item, then call the k_timer from the work item.&lt;/p&gt;
&lt;p&gt;Here is the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/kernel/threads/workqueue.html"&gt;documentation for workque threads and items&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;
&lt;p&gt;Edit: Updated faulty link.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/379435?ContentTypeID=1</link><pubDate>Mon, 01 Aug 2022 06:37:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2091fc87-3e46-49ec-88a1-ab008ac64b7a</guid><dc:creator>Mr.NCK</dc:creator><description>&lt;p&gt;Hi Helsing,&lt;/p&gt;
&lt;p&gt;We are stuck at this point. we need your assistance to move forward.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards&lt;/p&gt;
&lt;p&gt;Navin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/378915?ContentTypeID=1</link><pubDate>Wed, 27 Jul 2022 12:42:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:515474e5-35d7-4efc-b6f0-7c552d64135e</guid><dc:creator>Mr.NCK</dc:creator><description>&lt;p&gt;Hi Helsing,&lt;/p&gt;
&lt;p&gt;This is the actual problem we are facing&lt;/p&gt;
&lt;p&gt;We using NRF Connect SDK(zepher)&lt;/p&gt;
&lt;p&gt;1. After BLE is enabled, gpio interrupt handler is not at all gettting executed&lt;/p&gt;
&lt;p&gt;2. Regards the timer0 which we tried, we are getting os fault if we enable IRQ handler.&lt;/p&gt;
&lt;p&gt;3. is it possible to use timer0, timer1 and timer2 if ble is enabled and if yes please share the reference&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; regards,&lt;/p&gt;
&lt;p&gt;Navin&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/378872?ContentTypeID=1</link><pubDate>Wed, 27 Jul 2022 10:58:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6988baa-8ac1-4029-bb76-2f0d12ae7975</guid><dc:creator>Mr.NCK</dc:creator><description>&lt;p&gt;Hi Helsing,&lt;/p&gt;
&lt;p&gt;In the BLE application. I have tried to implement the below function.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;k_timer_start(&amp;amp;led_timer, &lt;/span&gt;&lt;span&gt;K_MSEC&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;5000&lt;/span&gt;&lt;span&gt;), &lt;/span&gt;&lt;span&gt;K_MSEC&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;5000&lt;/span&gt;&lt;span&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I haven&amp;#39;t gotten any compile error. But in the run time I can&amp;#39;t be able to see any output an as well my BLE advertisement also gets stopped.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thanks &amp;amp; Regards&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Navin&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Conflict between Timer Interrupt and BLE stack?</title><link>https://devzone.nordicsemi.com/thread/378722?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 12:59:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cccce063-d379-470c-811e-2ac9f6234233</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hi Navin,&lt;/p&gt;
&lt;p&gt;How have you implemented your timer?&lt;/p&gt;
[quote user=""]The code will not work properly.[/quote]
&lt;p&gt;How do you observe this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is your code based on any sample? Please check out the zephyr/samples/basic/button for an example showing how to use GPIOs.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>