<?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>Problem with direct interrupt / zero latency interrupt on nRF5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103842/problem-with-direct-interrupt-zero-latency-interrupt-on-nrf5340</link><description>Hello, 
 I&amp;#39;m currently trying to get a realtime regulation algorithm for the PWM0 module running. I use bare metal programming for the PWM and interrupts. My intention is to trigger an interrupt after each PWM period end, so that I can manually calculate</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 Sep 2023 08:09:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103842/problem-with-direct-interrupt-zero-latency-interrupt-on-nrf5340" /><item><title>RE: Problem with direct interrupt / zero latency interrupt on nRF5340</title><link>https://devzone.nordicsemi.com/thread/446593?ContentTypeID=1</link><pubDate>Tue, 19 Sep 2023 08:09:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7a0623d-feef-492a-bfab-934efabd3684</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Michael&lt;/p&gt;
&lt;p&gt;That is correct. If you don&amp;#39;t really interface with the Zephyr kernel at all from your interrupt there is no need to call ISR_DIRECT_PM().&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with direct interrupt / zero latency interrupt on nRF5340</title><link>https://devzone.nordicsemi.com/thread/446463?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2023 13:02:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdcacf4e-edf1-482c-86a5-93afee1e25e6</guid><dc:creator>puz_md</dc:creator><description>&lt;p&gt;Thanks for the detailed reply, Torbj&amp;oslash;rn. Clearing the event helped.&lt;/p&gt;
&lt;p&gt;As far as I know, I have to call ISR_DIRECT_PM() only if I want to trigger the scheduler (e.g. my interrupt triggers some context switch to a higher priority thread). This is not the case in my implementation, so I don&amp;#39;t call the macro according to the documentation that I have read. Especially as my interrupt is running at 16 kHz and the system tick is only 1 kHz if I remember correctly&lt;/p&gt;
&lt;p&gt;Can you confirm that I don&amp;#39;t need ISR_DIRECT_PM() in my scenario and that it is not mandatory to call it in EVERY direct isr implementation?&lt;/p&gt;
&lt;p&gt;Also thanks for forwarding the plugin bug to the VSCode team.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with direct interrupt / zero latency interrupt on nRF5340</title><link>https://devzone.nordicsemi.com/thread/446462?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2023 12:57:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e82ffe13-fa6a-4885-b0a6-582be62016d5</guid><dc:creator>puz_md</dc:creator><description>&lt;p&gt;Clearing the PWMPERIODEND event in my interrupt handler was actually what made it work. Thanks for the hint, Turbo J!&lt;/p&gt;
&lt;p&gt;I was falsely assuming that the PWM end is just communicated as an event (edge based) to the NVIC to trigger the interrupt bending bit, just like it does when triggering a task (which works fine in the background even without clearing the event bit).&lt;/p&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;ISR_DIRECT_DECLARE&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(&lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;pwm_isr&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;NRF_PWM0&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;EVENTS_PWMPERIODEND&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; = &lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;0&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;;&lt;/span&gt;&lt;span style="color:#6a9955;"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// This is needed to reset the pending interrupt and return to the calling context&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;m_pwm_interrupt_cnt&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;++;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color:#c586c0;"&gt;return&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; &lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;0&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with direct interrupt / zero latency interrupt on nRF5340</title><link>https://devzone.nordicsemi.com/thread/446455?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2023 12:47:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32208add-228d-4cd8-b823-6aa83b1627e5</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Michael&lt;/p&gt;
&lt;p&gt;It is true that you need to clear the event manually in the interrupt handler (clearing the pending flag in the NVIC is not required).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Potentially an interrupt could be&amp;nbsp;triggered by many different events, and the event handler will typically check the status of each event in turn, and clear it if set, before running the associated code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Secondly, when using the ISR_DIRECT_DECLARE() macro you should also use the ISR_DIRECT_PM() macro at the end of the interrupt handler.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For an example of this please have a look at &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/esb/esb.c#L1359-L1366"&gt;this interrupt handler&lt;/a&gt; from the ESB library.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you look at the implementation of the radio_irq_handler() function, &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/esb/esb.c#L1296"&gt;here&lt;/a&gt;, you can see that it checks if the event is enabled and clears it, as described above. It also checks if the event interrupt is enabled, but you can skip this if you are not planning to enable or disable interrupts for the event dynamically.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For the debugger issue,&amp;nbsp;I was able to reproduce this here. For some reason the VSCode debugger doesn&amp;#39;t properly interpret the ISER and ICER registers as an array, and they all point to the same register (ISER0).&amp;nbsp;&lt;br /&gt;If you try to read the register in the code, or debug with Ozone, the register values are correct.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will report this to the VSCode team and ask if they can look into it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with direct interrupt / zero latency interrupt on nRF5340</title><link>https://devzone.nordicsemi.com/thread/446416?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2023 08:02:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25cb760d-0311-4dfc-9493-c039a9b83a05</guid><dc:creator>puz_md</dc:creator><description>&lt;p&gt;You mean the PWMPERIODEND event in the pwm module? I could try that...&lt;/p&gt;
&lt;p&gt;Is the NVIC state (clear pending interrupt) handled automatically by the macro definition? (If yes, will the pending flag be reset in the header or the footer? Just to be sure what happens in the case of a timeslice overrun of the interrupt code).&lt;/p&gt;
&lt;p&gt;And concerning the NVIC screenshot during debug, do you know what&amp;#39;s the issue with it? Is this a nRF Connect SDK bug?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with direct interrupt / zero latency interrupt on nRF5340</title><link>https://devzone.nordicsemi.com/thread/446352?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 17:34:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e89f6ed9-8d03-4c01-9fc0-1f3c302ffbd9</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;The isr function must reset the condition that trigerred the interrupt. Otherwise the processor just keeps tail-chanining into the function again.&lt;/p&gt;
&lt;p&gt;Your function does not do that, and runs at highest possible priority - so nothing else can preempt it either.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>