<?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>Does the SPIS clear its END interrupt when a new transaction starts?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9503/does-the-spis-clear-its-end-interrupt-when-a-new-transaction-starts</link><description>Dear all, 
 I have written some code that controls the SPIS and allows it to transfer data as if it were a master. I am generating the SPIS clock from one timer, and I am looping back a pin to control the CSN line for the SPIS. The CSN is controlled</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 05 Oct 2015 14:13:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9503/does-the-spis-clear-its-end-interrupt-when-a-new-transaction-starts" /><item><title>RE: Does the SPIS clear its END interrupt when a new transaction starts?</title><link>https://devzone.nordicsemi.com/thread/35074?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2015 14:13:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58cdb7a3-69a9-4289-993c-6a6d88e83df5</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Any time. I am glad that you figured out the issue&lt;/p&gt;
&lt;p&gt;PS. If you do not have enough CPU time for your scenario, nRF52 has an Cortex M4, which is much faster ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does the SPIS clear its END interrupt when a new transaction starts?</title><link>https://devzone.nordicsemi.com/thread/35073?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2015 14:09:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3453dd32-5035-4164-b57b-83af084e7797</guid><dc:creator>Peter Myerscough-Jackopson</dc:creator><description>&lt;p&gt;It appears it may have simply been a starvation issue, as you suggest. I placed a simple LED toggle function in the spi handler and it toggles infrequently. I am also running in debug mode, so optimisations would not have reduced my code.&lt;/p&gt;
&lt;p&gt;Sorry for the noise, and thank you for the help,&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does the SPIS clear its END interrupt when a new transaction starts?</title><link>https://devzone.nordicsemi.com/thread/35072?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2015 13:51:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1e135cb-4d69-4fa9-a379-0335f8b2078d</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Peter&lt;/p&gt;
&lt;p&gt;The way it is performed in the SPIS driver in the SDK:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The SPI master sets CSN line high which ends the transaction and generates the SPIS-&amp;gt;END event&lt;/li&gt;
&lt;li&gt;The END_ACQUIRE shortcut is set, making the semaphore to be acquired immediately after the SPIS-&amp;gt;END event is received&lt;/li&gt;
&lt;li&gt;The SPIS-&amp;gt;END event is cleared in SPIS-&amp;gt;END interrupt handler&lt;/li&gt;
&lt;li&gt;The ACQUIRED event is cleared in the SPIS-&amp;gt;ACQUIRED interrupt handler and the buffer operations are performed&lt;/li&gt;
&lt;li&gt;Semaphore is released when buffer operations are completed, which will allow the SPIS to send/receive more data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The state machine for the above sequence is shown &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/hardware_driver_spi_slave.html?cp=4_1_0_2_7"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I have the following understanding of your case, correct me as necessary:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When you receive the high priority interrupt, you manually set the CSN high, which ends the transaction and generates the SPIS-&amp;gt;END event&lt;/li&gt;
&lt;li&gt;The END_ACQUIRE shortcut is set so the semaphore is requested as soon as the END event is generated by SPIS.&lt;/li&gt;
&lt;li&gt;You clear the END event in the END event handler&lt;/li&gt;
&lt;li&gt;You do not wait for the ACQUIRED event, but instead read buffer data and release the ACQUIRED event in a high priority interrupt, without knowing if the ACKUIRED event has been received or not.&lt;/li&gt;
&lt;li&gt;You end the high priority interrupt with setting CSN low, allowing SPIS to operate if CLK signal is generated with your TIMER&lt;/li&gt;
&lt;li&gt;In the ACQUIRED event handler, you release the semaphore again with calling SPIS-&amp;gt;RELEASE task, since there are no buffers to relocate.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If this high priority interrupt is generated with high frequency, I suspect that one of the following may happen:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The high frequency interrupt starves the SPIS-&amp;gt;END low priority interrupt, because as soon as one high frequency interrupt ends, another one begins. Processing time of the high priority interrupt may take a long time if considerable amount of data has to be copied from the SPIS RX buffer to the FIFO buffer.&lt;/li&gt;
&lt;li&gt;The ACQUIRED event handler has not been executed before starting SPIS transmission, therefore the semophore has not been released. In this case  all incoming data is ignored by SPIS, and you will probably not receive SPIS-&amp;gt;END event when CSN goes high again, since this would not be a valid transaction.&lt;/li&gt;
&lt;li&gt;You release the semaphore in your high priority interrupt before it has been acquired, which has no effect. When you set the CSN low again, the semaphore has been acquired by the CPU, so the SPIS can not acquire it, making the SPIS to ignore the following transaction and not generate any SPIS-&amp;gt;END event.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The above is just speculation in order to give you ideas of possible failure scenarios. I feel I do not understand your scenario or sequence sufficiently yet do draw any conclusions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does the SPIS clear its END interrupt when a new transaction starts?</title><link>https://devzone.nordicsemi.com/thread/35070?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2015 08:16:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47390b1e-8b4c-46f7-97dd-a9ce1036b9bf</guid><dc:creator>Peter Myerscough-Jackopson</dc:creator><description>&lt;p&gt;Stefan,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I am not &amp;#39;actively&amp;#39; checking/acquiring the interrupt, but...&lt;/li&gt;
&lt;li&gt;I do have the END_ACQUIRE shortcut enabled, and in the high priority interrupt handler I am releasing the semaphore.&lt;/li&gt;
&lt;li&gt;I am not changing the buffers because I am reusing all the buffer locations. I am performing an SPI read operation that the external device requires a single byte command to start. I am setting the TXDPTR to point to a buffer holding this command, as well as writing the byte to the ORC and DEF registers.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The read data is being copied from the buffer the SPIS points to, into a FIFO, but the pointer in the SPIS is not changed.&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does the SPIS clear its END interrupt when a new transaction starts?</title><link>https://devzone.nordicsemi.com/thread/35071?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2015 17:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e54b809a-9201-4d7b-b832-38d99b3fa1cc</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Peter&lt;/p&gt;
&lt;p&gt;Thanks for you question&lt;/p&gt;
&lt;p&gt;Where are you acquiring the semaphore?
Do you have the END_ACQUIRE shortcut enabled?
Are you not waiting for the ACQUIRED event before proceeding with the buffer operation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>