<?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>SPIS - Execution order in spis_irq_handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96022/spis---execution-order-in-spis_irq_handler</link><description>I have for some while had a project running in which NRF52840 operates in SPI slave mode. Using &amp;quot;modules\hal\nordic\nrfx\drivers\src\nrfx_spis.c&amp;quot; 
 Lately i have been stressing the system with higher data throughput in both direction and is observing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Jan 2023 15:05:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96022/spis---execution-order-in-spis_irq_handler" /><item><title>RE: SPIS - Execution order in spis_irq_handler</title><link>https://devzone.nordicsemi.com/thread/406713?ContentTypeID=1</link><pubDate>Thu, 26 Jan 2023 15:05:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a79bc71-ff9e-49c9-818d-72c7eb613cfb</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Anders_e"]&lt;p&gt;Surely the setup of upcoming buffers needs to be done fast in order to be ready for next transmission to avoid &amp;quot;DEF&amp;quot; output situation that will require retransmisson. However I still need securely detect incoming data from previous transaction.&amp;nbsp; When the events occur simultanously i don&amp;#39;t see how to distinguish between the two buffer set.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As it is allowed to update the buffers (hence aquire the semaphore) repeately until transaction is started (CSN active), you cannot tell if the buffer update occures before or after the actual transaction, given the current isr execution order.&lt;/p&gt;
&lt;p&gt;I have an inter-packet time of 1 ms on the master side, so there should be enough time for processing. However the issue arrises when i have tx data that updates the spi buffers asynchronusly. When this happens during active transaction the update will be pendingm and the isr events occurs simultanously when CSN is going inactive, causing buffer update before beeing able to catch incoming data.&lt;/p&gt;
&lt;p&gt;In other words since there is no 1:1 relation &lt;span&gt;BUFFER_SET_DONE&amp;nbsp;and&amp;nbsp;XFER_DONE.&amp;nbsp;&lt;/span&gt;I need to have link between buffer setup and transaction complete to be sure to process the right buffer. When the &amp;quot;BUFFER_SET_DONE&amp;quot; is &amp;quot;overtaking&amp;quot; the XFER_DONE, in the isr it seem that this link is broken.&amp;nbsp; Reversing the execution order will ensure that the&amp;nbsp;&amp;quot;XFER_DONE&amp;quot; is related to the latest&amp;nbsp;&lt;span&gt;BUFFER_SET_DONE.&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Since you have an asynchonous update of the buffer, I understand that this can be problematic.&lt;/p&gt;
&lt;p&gt;Could you rather only update the buffer when the&amp;nbsp;XFER_DONE&amp;nbsp;event occurs? This should allow you do synchronize towards the SPIS transfer flow.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you see any performance change when disabling or deferring the log from the event handler?&lt;/p&gt;
[quote user="Anders_e"]Regarding scoping&amp;nbsp;&lt;span&gt;inactive to active CSN, do you mean measurering on wire ?&amp;nbsp; Unfortunately I currently have no access to the physical connections (ie. no test points and everything routed in internal PCB layers).&amp;nbsp;&lt;/span&gt;[/quote]
&lt;p&gt;Yes, looking at the CSN/MISO/MOSI/CLK lines with a logic analyzer to see the timing of the bus, just to see that it behaves as you&amp;#39;d expect it to. This is very helpful if you experience any issues in the transport layer. Does the external sensor have a QFN package? If so, you can technically be able to solder on some &amp;quot;ears&amp;quot; (very thin wire) to the specific pins.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIS - Execution order in spis_irq_handler</title><link>https://devzone.nordicsemi.com/thread/406422?ContentTypeID=1</link><pubDate>Wed, 25 Jan 2023 10:42:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1268e077-d6fe-457b-b403-92922d44a3fb</guid><dc:creator>Anders Esbensen</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon&lt;/p&gt;
&lt;p&gt;Thank you for fast reply.&lt;/p&gt;
&lt;p&gt;Surely the setup of upcoming buffers needs to be done fast in order to be ready for next transmission to avoid &amp;quot;DEF&amp;quot; output situation that will require retransmisson. However I still need securely detect incoming data from previous transaction.&amp;nbsp; When the events occur simultanously i don&amp;#39;t see how to distinguish between the two buffer set.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As it is allowed to update the buffers (hence aquire the semaphore) repeately until transaction is started (CSN active), you cannot tell if the buffer update occures before or after the actual transaction, given the current isr execution order.&lt;/p&gt;
&lt;p&gt;I have an inter-packet time of 1 ms on the master side, so there should be enough time for processing. However the issue arrises when i have tx data that updates the spi buffers asynchronusly. When this happens during active transaction the update will be pendingm and the isr events occurs simultanously when CSN is going inactive, causing buffer update before beeing able to catch incoming data.&lt;/p&gt;
&lt;p&gt;In other words since there is no 1:1 relation &lt;span&gt;BUFFER_SET_DONE&amp;nbsp;and&amp;nbsp;XFER_DONE.&amp;nbsp;&lt;/span&gt;I need to have link between buffer setup and transaction complete to be sure to process the right buffer. When the &amp;quot;BUFFER_SET_DONE&amp;quot; is &amp;quot;overtaking&amp;quot; the XFER_DONE, in the isr it seem that this link is broken.&amp;nbsp; Reversing the execution order will ensure that the&amp;nbsp;&amp;quot;XFER_DONE&amp;quot; is related to the latest&amp;nbsp;&lt;span&gt;BUFFER_SET_DONE.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regarding CONFIG_LOG_MODE_DEFERRED that a good point,&amp;nbsp; i will try that out, however i have very limit log in the isr/event handler.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regarding scoping&amp;nbsp;&lt;span&gt;inactive to active CSN, do you mean measurering on wire ?&amp;nbsp; Unfortunately I currently have no access to the physical connections (ie. no test points and everything routed in internal PCB layers).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Anders&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIS - Execution order in spis_irq_handler</title><link>https://devzone.nordicsemi.com/thread/406410?ContentTypeID=1</link><pubDate>Wed, 25 Jan 2023 09:34:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:232995b2-7481-4d86-aa3d-8c561567bc75</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Effectively, the SPIS needs to setup the upcoming buffers before the CSN pin goes active.&lt;/p&gt;
&lt;p&gt;If you have an application that requires you to parse the incoming data before setting up the buffer, this can be tight when pushing high throughput.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you logging from the ISR/event_handler? If so, you need to ensure that the logger thread is running in a deferred mode (ie. handling log data at a later point) via CONFIG_LOG_MODE_DEFERRED.&amp;nbsp;&lt;/p&gt;
[quote user=""]Reversing the order in the &amp;quot;isr&amp;quot; seems to solve the issue and to me it also seems logical to process the completed transaction before setting up new buffers and not the other way around.[/quote]
&lt;p&gt;Have you scoped the lines to see how much delay (ie. processing time) is between each inactive to active CSN?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>