<?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>SPI timeout when calling from ISR</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90921/spi-timeout-when-calling-from-isr</link><description>I currently have an application that buffers signals by recording with an ADC on an interrupt and then retransmits the data using an external DAC through SPI. When I call any SPI functions such as spi_write from anywhere outside of an ISR it works as</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 05 Dec 2022 19:26:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90921/spi-timeout-when-calling-from-isr" /><item><title>RE: SPI timeout when calling from ISR</title><link>https://devzone.nordicsemi.com/thread/399055?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 19:26:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5629de9-9132-4734-a8ea-35a948fae40f</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;I&amp;#39;ve hit this same issue but this discussion doesn&amp;#39;t offer any advice on what you should do instead.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;So for anyone else stumbling across this post, I&amp;#39;ve fixed it on my project by using an application work queue to get my SPI reads done as quickly as possible after exiting the ISR. My ISR just calls&amp;nbsp;k_work_submit_to_queue to kick off my function that performs the SPI reads.&lt;/p&gt;
&lt;p&gt;Good video describing work queues here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=LDTjncHNBpU"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Another devzone thread with a chunk of code you can copy and use to create your own work queue (currently it&amp;#39;s the bottom post in the discussion) here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/91797/no-heap-space-for-incoming-notifications/388632"&gt;devzone.nordicsemi.com/.../388632&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You could also probably use the system work queue, but making an application queue&amp;nbsp;lets me&amp;nbsp;set the priority.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI timeout when calling from ISR</title><link>https://devzone.nordicsemi.com/thread/381344?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2022 11:40:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c9dcdd2-914f-446a-81c1-25f582114d3f</guid><dc:creator>Albrecht Markus Schellenberger</dc:creator><description>&lt;p&gt;&lt;span&gt;Hello Ethan,&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
[quote user=""]When spi_write is called during the execution of an ISR it always results in an error code of 116 which implies the SPI writing is timing out. Is there something that I am missing about using SPI in interrupts?[/quote]
&lt;p&gt;&lt;span&gt;Referring to chapter &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/kernel/services/interrupts.html#offloading-isr-work"&gt;Offloading ISR Work&lt;/a&gt; in the Zephyr documentation.&lt;/span&gt;&lt;span&gt; &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You are not supposed to call time/resource-consuming processes from any ISR. The &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/zephyr/hardware/peripherals/index.html#peripherals"&gt;Peripheral APIs&lt;/a&gt; go definitely under this umbrella.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Cheers,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Markus&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>