<?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>Zephyr work queue and interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89330/zephyr-work-queue-and-interrupt</link><description>Hello, 
 We are developing an application using nrf52832 and the ncs 1.8.0. 
 Since our solution is battery operated we have configures application to sleep by default and wake-up on the interrupt. 
 In our case, this interrupt is PWM like pulses. So</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Jul 2022 16:42:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89330/zephyr-work-queue-and-interrupt" /><item><title>RE: Zephyr work queue and interrupt</title><link>https://devzone.nordicsemi.com/thread/376068?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2022 16:42:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3e74808-0d1c-432e-9e9f-e7f6de40a85e</guid><dc:creator>embeddedER</dc:creator><description>&lt;p&gt;Thanks Einar. We are using&amp;nbsp;normal sleep/idle mode. So, as you suggest, should not affect the power consumption.&lt;/p&gt;
&lt;p&gt;I shall check and get back to you if I&amp;#39;ve more questions here.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;TIA!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr work queue and interrupt</title><link>https://devzone.nordicsemi.com/thread/375495?ContentTypeID=1</link><pubDate>Tue, 05 Jul 2022 09:24:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90c4a184-f587-4c65-96db-73ef0271532d</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;I assume that by deep sleep you are referring to &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fpower.html&amp;amp;cp=4_2_0_17_1&amp;amp;anchor=unique_2047546596"&gt;System OFF mode&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;In that case&amp;nbsp;no threads are running while in System OFF mode and on wakeup the system is reset, so waiting for a semaphore in deep sleep wouldn&amp;#39;t make much sense.&lt;/p&gt;
&lt;p&gt;If you are referring to normal sleep/idle mode, then waiting for a semaphore would not consume more power than just idling, and would be the recommended way to wait for an interrupt in a power constrained system.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr work queue and interrupt</title><link>https://devzone.nordicsemi.com/thread/375168?ContentTypeID=1</link><pubDate>Fri, 01 Jul 2022 20:08:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca75cb09-53ec-4360-9496-7c7a43b4e430</guid><dc:creator>embeddedER</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&amp;nbsp;semaphore is what I was thinking to use for synchronization, however, it will still need my thread to be created at the start and then it will always be running in wait state. Since, most of the time we are in deep sleep, I was thinking to start the thread only when needed and then stop it completely (rather then waiting) when not needed.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Does thread waiting for semaphore in deep sleep consume more power?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;TIA!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr work queue and interrupt</title><link>https://devzone.nordicsemi.com/thread/375032?ContentTypeID=1</link><pubDate>Fri, 01 Jul 2022 09:14:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7de223f5-b09c-4905-9fe5-c47f4697fec3</guid><dc:creator>Sigurd</dc:creator><description>[quote user="harshal034"]We are particularly looking for a way to get around starting a thread before the interrupt arrives. And we want our worker thread to initiate as soon as first interrupt arrives.[/quote]
&lt;p&gt;Maybe you can use a&amp;nbsp;semaphore. At the start of the&amp;nbsp;processing function:&lt;/p&gt;
&lt;p&gt;k_sem_take(&amp;amp;waiting_for_irq, K_FOREVER);&lt;/p&gt;
&lt;p&gt;in the irq:&lt;/p&gt;
&lt;p&gt;k_sem_give(&amp;amp;&lt;span&gt;waiting_for_iq&lt;/span&gt;);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr work queue and interrupt</title><link>https://devzone.nordicsemi.com/thread/374404?ContentTypeID=1</link><pubDate>Mon, 27 Jun 2022 18:50:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b64df681-f38e-48d9-9477-6b3c3b7254a4</guid><dc:creator>embeddedER</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For our case, we need to know the pulse duration between every PWM pulse and make some necessary decisions.&amp;nbsp;Our PWM duration is in milli seconds range (10-100).&lt;/p&gt;
&lt;p&gt;We already have a code developed and tested that can calculate&amp;nbsp;every PWM pulse duration and calculate the moving average and diff of pules. Currently, how we do this is, we start&amp;nbsp;a thread first that&amp;nbsp;does processing of this Pulse difference data and then we enable the interrupt. This works fine. PPI example, more or less does same thing.&lt;/p&gt;
&lt;p&gt;However, since we&amp;nbsp;have a battery operated device, we are in deep sleep mode by default and we want our system to wake-up when first interrupt arrives and at the same time we want to start that processing thread. However, as I mentioned above we can&amp;#39;t start the thread from the interrupt context and if I submit a system Queue from the interrupt context, it kicks of the thread after several seconds.&lt;/p&gt;
&lt;p&gt;We are particularly looking for a way to get around starting a thread before the interrupt arrives. And we want our worker thread to initiate as soon as first interrupt arrives.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;TIA!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr work queue and interrupt</title><link>https://devzone.nordicsemi.com/thread/374274?ContentTypeID=1</link><pubDate>Mon, 27 Jun 2022 07:49:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43092524-43ae-4c3d-a183-de0108d8f547</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Not&amp;nbsp;sure what&amp;#39;s the signal frequency and the accuracy needed for your application here, but using PPI+TIMER+GPIOTE is likely the better option here. Here is some code that you can use as a template.&amp;nbsp;&lt;a href="https://github.com/sigurdnev/ncs-playground/blob/master/samples/pulse_detector/src/main.c"&gt;https://github.com/sigurdnev/ncs-playground/blob/master/samples/pulse_detector/src/main.c&lt;/a&gt;&amp;nbsp;(orginally based on the code in this post &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/34547/ppi-configuration-to-count-pulses"&gt;PPI Configuration to Count Pulses&lt;/a&gt;&amp;nbsp; )&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>