<?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>Clarity Around Interrupt Priorities</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105366/clarity-around-interrupt-priorities</link><description>I&amp;#39;ve read the documentation but it doesn&amp;#39;t seem to entirely gel with what I&amp;#39;m having to do to make everything work, so I thought it would be worth a post. I have 4 priorities: Ideally I wanted scheduler to run before the lower priority softdevice calls</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 07 Nov 2023 19:52:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105366/clarity-around-interrupt-priorities" /><item><title>RE: Clarity Around Interrupt Priorities</title><link>https://devzone.nordicsemi.com/thread/454548?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 19:52:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a69f645-8116-43ad-93e1-3dc67bc619fe</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Your assumption is quite correct; an active level 5 interrupt service routine will be interrupted by an exception linked to an enabled level 4 interrupt.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This example considers three exceptions with configurable priority:&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;bull; A has highest priority, described as priority A.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;bull; B has medium priority, described as priority B.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;bull; C has lowest priority, described as priority C.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;Consider the following sequence of events:&lt;/em&gt;&lt;br /&gt;&lt;em&gt;1. Exception B occurs. The processor takes the exception and starts executing the handler for this exception.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;The execution priority is priority B.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;2. Exception A occurs. Because its priority is higher than the execution priority, it preempts exception B and&amp;nbsp;&lt;/em&gt;&lt;em&gt;the processor starts executing the Exception A handler. Execution priority is now priority A.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;3. Exception C occurs. Its priority is less than the execution priority so its status is pending.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;4. The handler for exception A reduces the priority of exception A, to a priority lower than priority C. The&amp;nbsp;&lt;/em&gt;&lt;em&gt;execution priority falls to the highest priority of all active exceptions. This is priority B.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;Exception C remains pending because its priority is lower than the current execution priority.&amp;nbsp;&lt;/em&gt;&lt;em&gt;Only a pending exception with higher priority than priority B can preempt the current exception handler.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;Therefore, a new exception with lower priority than exception B cannot take precedence over the preempted&amp;nbsp;&lt;/em&gt;&lt;em&gt;exception B.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.arm.com/documentation/ddi0403/latest/"&gt;https://developer.arm.com/documentation/ddi0403/latest/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarity Around Interrupt Priorities</title><link>https://devzone.nordicsemi.com/thread/454403?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 10:48:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4457f1e6-b560-4219-9f02-642293f87d90</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Great explanation thanks, that&amp;#39;s a Cortex feature I hadn&amp;#39;t came across yet. I assumed there was some memory identifiers buried within a config file within the sdk. Assumptions eh!&lt;br /&gt;&lt;br /&gt;There was no benefit to having the scheduler interrupt calls serviced outside the interrupt other than to run at the lowest priority and it added a little overhead checking the event flags. I did however make another assumption and that is an interrupt at priority 4 would literally interrupt an interrupt at priority 5 and then jump back in afterwards. Reading up I&amp;#39;m unsure now if this is the case, or whether a queue develops and when it comes to servicing it the highest priority is chosen first.&lt;br /&gt;&lt;br /&gt;I can&amp;#39;t recall now why the scheduler was higher priority but I just tried it at 7 and it works the same. I think at the time I expected the ADC looping to hit it (there&amp;#39;s some computational work being done inside the interrupt).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarity Around Interrupt Priorities</title><link>https://devzone.nordicsemi.com/thread/454364?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 09:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43d1cb1f-1927-4dfb-a1f2-3244a2379b4b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Andrew&lt;/p&gt;
&lt;p&gt;All the SoftDevice functions are using so called SVC function calls (also called supervisor calls), and will run in a software interrupt at interrupt level 4 as shown &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=5_7_4_0_15_1"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The SVC mechanism associates each function call with a unique 8-bit number, and executes the function itself from an interrupt.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;An advantage of this is that the application doesn&amp;#39;t need to know where the various functions are located in the SoftDevice, it only needs to be able to trigger the SVC mechanism. This is what makes it possible to compile and link your application completely independently of the SoftDevice, and is a critical aspect of the SoftDevice architecture.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The drawback of this method is that if you try to call a SoftDevice function from an interrupt at level 4 or higher the SVC call will be blocked by the code calling it, and your application will crash.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Running a scheduler from interrupt context seems a bit odd. How much time do you expect to spend running the scheduler?&amp;nbsp;&lt;br /&gt;And if you are to do this wouldn&amp;#39;t it make more sense to assign the lowest interrupt priority (7) to the scheduler, so that other interrupts can supersede 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: Clarity Around Interrupt Priorities</title><link>https://devzone.nordicsemi.com/thread/454162?ContentTypeID=1</link><pubDate>Mon, 06 Nov 2023 10:45:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c942ec2b-7252-4157-9704-27c1ca521499</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;No this is a home brew scheduler. That explains why I have to run it at priority 5, so it seems the priorities are also acting as a security &amp;#39;firewall&amp;#39; of sorts.&lt;br /&gt;&lt;br /&gt;It would be good to understand this a little more, like the calls themselves are just jumps with nothing to do with priorities? I don&amp;#39;t see how they can be restricted to only operate by callers operating at a particular priority level?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarity Around Interrupt Priorities</title><link>https://devzone.nordicsemi.com/thread/454146?ContentTypeID=1</link><pubDate>Mon, 06 Nov 2023 10:16:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a46f8d6-feb9-4fc5-99fe-c3ab2aac5e7c</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Andrew&lt;/p&gt;
&lt;p&gt;By scheduler do you mean the app_scheduler library?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you running the app_sched_execute() function from an interrupt?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The idea behind this library is to schedule execution from the main context, and usually app_sched_execute() is simply called from the main loop before entering sleep. Then you can safely schedule callbacks from any interrupt context, and have it executed from the main context once all interrupts are finished.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Running this from an interrupt is not tested, and I am not sure how well this will work.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any code that makes calls into the SoftDevice will need to run at priority 5 or lower (higher number), otherwise it won&amp;#39;t work.&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></channel></rss>