<?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>nrf52 + NRF SDK 17.1.0 - looking for semaphore to signal from interrupt to main loop</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118762/nrf52-nrf-sdk-17-1-0---looking-for-semaphore-to-signal-from-interrupt-to-main-loop</link><description>Hi ! I&amp;#39;m using nrf52 + SDK 17.1.0. 
 I found sd_mutex_acquire/ sd_mutex_release, which is great for locking variables that are set/get asynchronously. Next, I&amp;#39;d like to use something like a semaphore, so I can indicate from my interrupt to the main loop</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 09 Feb 2025 19:45:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118762/nrf52-nrf-sdk-17-1-0---looking-for-semaphore-to-signal-from-interrupt-to-main-loop" /><item><title>RE: nrf52 + NRF SDK 17.1.0 - looking for semaphore to signal from interrupt to main loop</title><link>https://devzone.nordicsemi.com/thread/522111?ContentTypeID=1</link><pubDate>Sun, 09 Feb 2025 19:45:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5807a7b6-d8dc-4381-b566-3036bfb99c23</guid><dc:creator>ms360</dc:creator><description>&lt;p&gt;Scheduler was super simple to get working.&amp;nbsp;&lt;br /&gt;I was stuck in my FreeRTOS ways.&amp;nbsp;&lt;br /&gt;Thanks Emil!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 + NRF SDK 17.1.0 - looking for semaphore to signal from interrupt to main loop</title><link>https://devzone.nordicsemi.com/thread/522107?ContentTypeID=1</link><pubDate>Sun, 09 Feb 2025 16:14:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae87c9b4-19a2-4abd-b2f0-6af8a930b9d8</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;If your interrupt handlers are configured to use the same interrupt priority, they will run in irq number order if multiple interrupts are pending at the same time.&lt;/p&gt;
&lt;p&gt;The sdk is by default designed to use interrupts and priorities, but there is an optional scheduler module that you can use that already integrates well with the soft device and timer module, see&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/guides/short-range-guides/b/software-development-kit/posts/scheduler-tutorial"&gt;devzone.nordicsemi.com/.../scheduler-tutorial&lt;/a&gt;. With this design, you put events in a queue from interrupt handlers which are then dispatched in order from the main context.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 + NRF SDK 17.1.0 - looking for semaphore to signal from interrupt to main loop</title><link>https://devzone.nordicsemi.com/thread/522106?ContentTypeID=1</link><pubDate>Sun, 09 Feb 2025 16:00:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dcdf2f6-f8d8-45d8-94eb-f316858d7383</guid><dc:creator>ms360</dc:creator><description>&lt;p&gt;Thanks Emil..&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So instead of signalling the main loop of an event, SWI/EGU would be running the event triggered code in a lower priority callback?&lt;/p&gt;
&lt;p&gt;What if you wanted things to be checked in the main loop and run in a specific order? IE - service a timer before servicing a UART. I don&amp;#39;t usually design things like this, relying on priorities to dictate processing order, rather than explicit main loop handling.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Am I SOL on my preferred design pattern?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 + NRF SDK 17.1.0 - looking for semaphore to signal from interrupt to main loop</title><link>https://devzone.nordicsemi.com/thread/522098?ContentTypeID=1</link><pubDate>Sun, 09 Feb 2025 10:09:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bb6fed9-fbca-4ac0-b199-a357b7bf33a5</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;I suggest that you use SWI or EGU (event generator unit) instead and then run your desired event in an interrupt handler at your desired interrupt priority level (typically lower than your peripheral interrupt level). That&amp;#39;s how the rest of the sdk is designed to work. The main loop should be as short as possible and go to WFI or WFE as quickly as possible to not consume too much energy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>