<?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 scheduler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16434/nrf52-scheduler</link><description>I am creating a system (nRF52 SDK11.0.0 s132) that will get a data ready interrupt on a GPIO (configured via GPIOTE with a handler) from a sensor every 4ms. The sensor has an SPI slave interface for reading the data. The handler will either set a flag</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Sep 2016 07:03:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16434/nrf52-scheduler" /><item><title>RE: nRF52 scheduler</title><link>https://devzone.nordicsemi.com/thread/62885?ContentTypeID=1</link><pubDate>Mon, 19 Sep 2016 07:03:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea8432cb-8704-47f8-a84f-824ffd507803</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;When using a SoftDevice on the nRF52 there are &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=2_3_0_0_15_1"&gt;4 interrupt priorities available to the application&lt;/a&gt;. Though the SDK mostly use only 2, there is support for using all 4, which are defined by the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/group__app__util__platform.html#ga1a193131d1d5911b1ec53f9541841b1b"&gt;&lt;code&gt;app_irq_priority_t&lt;/code&gt;&lt;/a&gt; enum.&lt;/p&gt;
&lt;p&gt;Another thing which you should remember is that if you have a BLE link active, BLE event will have high priority, and can delay high priority application interrupts. The details about this is found in &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/processor_avail_interrupt_latency/ble_usage_patterns.html?cp=2_3_0_0_15_2_2"&gt;BLE processor usage patterns&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 scheduler</title><link>https://devzone.nordicsemi.com/thread/62884?ContentTypeID=1</link><pubDate>Mon, 19 Sep 2016 06:50:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:789483f3-5de4-4cd3-a2b4-cbd4ca05fa14</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Regarding GPIOTE, the interrupt priority is configurable, and is set in the driver configuration header file. For example, in the GPIOTE example in SDK 11, you can see the following line in the driver configuration file (examples/peripheral/gpiote/config/gpiote_pca10040/):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define GPIOTE_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also configure the interrupt priority of the SPI master driver. It is done by setting the &lt;code&gt;irq_priority&lt;/code&gt; field of the &lt;code&gt;nrf_drv_spi_config_t&lt;/code&gt; struct, that is passed to &lt;code&gt;nrf_drv_spi_init()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You are right that if you have two interrupts of same priority, the first interrupt routine will finish before the second has time to run. A higher priority interrupt on the other hand will result in immediately servicing the new (high priority) interrupt. The ISR of the lower priority interrupt will continue when the higher priority ISR has finished.&lt;/p&gt;
&lt;p&gt;You do not have to use blocking SPI reads, particularly, it does not seems sensible to do &lt;em&gt;blocking&lt;/em&gt; reads from a interrupt / event handler.&lt;/p&gt;
&lt;p&gt;Regarding the application timer, it may not be useful as you anyway get a ready signal from the sensor   every time you need to sample data. I must have missed that information when I wrote the initial question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 scheduler</title><link>https://devzone.nordicsemi.com/thread/62886?ContentTypeID=1</link><pubDate>Sat, 17 Sep 2016 19:20:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdc51461-a134-4ae9-825e-2c98a96f8d33</guid><dc:creator>Tosa</dc:creator><description>&lt;p&gt;Actually I&amp;#39;m using SDK11.0.0 (updated my question to reflect this), but noticed that SDK12.0.0 sets the GPIOTE IRQ priority to 6, so the SPI IRQ priority could be set higher. Einar (or other Nordic employees): any comments? Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 scheduler</title><link>https://devzone.nordicsemi.com/thread/62883?ContentTypeID=1</link><pubDate>Thu, 15 Sep 2016 20:53:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8806347-7572-424c-9c8f-3c3e387433ad</guid><dc:creator>Tosa</dc:creator><description>&lt;p&gt;GPIOTE uses _PRIO_APP_HIGH (=2). If I call the blocking SPI read directly from the GPIOTE handler, will SPI function properly with _PRIO_APP_LOW (=6)? And even if it matches the GPIOTE priority, will it still work since it cannot preempt another interrupt of the same priority? Would the similar concept apply if using the application timer, except that in this case the SPI priority could be set higher than the timer priority?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 scheduler</title><link>https://devzone.nordicsemi.com/thread/62882?ContentTypeID=1</link><pubDate>Thu, 15 Sep 2016 05:53:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a9700cd-20a7-4598-9835-73559d71efff</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The way I understand it, the main point is that your algorithm &amp;quot;task&amp;quot; needs to run with a lower priority than the sampling. The scheduler from the SDK does not have a concept of priorities, but you could for example use the scheduler (or another custom mechanism) to move the algorithm to the main context. The sampling and SPI read could be in a higher interrupt priority context, where you handle it directly in the interrupt routine / event handler. Typically you would use the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.0.0%2Flib_timer.html&amp;amp;cp=4_0_0_3_27"&gt;application timer&lt;/a&gt; to sample at a regular interval, and the priority would be &lt;code&gt;APP_LOW&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>