<?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>Interrupt seems to be starving main loop, but timing doesn&amp;#39;t agree.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114259/interrupt-seems-to-be-starving-main-loop-but-timing-doesn-t-agree</link><description>Hi all, 
 
 I have a problem that seems very simple, but I cannot make sense of it. 
 
 I have a simple setup on the NRF52840 DK that senses a rising edge on pin 1.00 and then sets pin 1.01 high along with a flag. I then have a while loop in my main that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Aug 2024 10:20:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114259/interrupt-seems-to-be-starving-main-loop-but-timing-doesn-t-agree" /><item><title>RE: Interrupt seems to be starving main loop, but timing doesn't agree.</title><link>https://devzone.nordicsemi.com/thread/500173?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 10:20:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:412b9bda-7a32-4c57-aec6-6f337b33b5da</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It is not clear where (which context) you are printing those logs. It is not clear what other contexts exist in your application.&lt;/p&gt;
&lt;p&gt;If k_sleep helped you in your case, then it could be that where ever you introduced the k_sleep will invoke the RTOS scheduler to possible make other contexts run.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It looks like you do not have good control on which contexts are running when. To be able to calibrate the thread priorities and timing, I strongly recommend you to run your application with &lt;a href="https://www.zephyrproject.org/tracing-zephyr-applications-with-segger-systemview/"&gt;Tracing &lt;/a&gt;using &lt;a href="https://www.segger.com/products/development-tools/systemview/"&gt;SystemView&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You will get a nice visual view of what thread is blocking which thread like below and this helps you calibrate your thread priorities.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1724840516274v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupt seems to be starving main loop, but timing doesn't agree.</title><link>https://devzone.nordicsemi.com/thread/500081?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2024 22:41:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a496ddc4-6072-4cb9-b6c6-4c4ec4f7f491</guid><dc:creator>coder123</dc:creator><description>&lt;p&gt;Apparently adding a&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;k_sleep&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;K_NSEC&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1&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;to the bottom of the while loop makes it work. Not exactly sure why but good enough.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>