<?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>Is it possible to start SPIS after CSN is already low?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103798/is-it-possible-to-start-spis-after-csn-is-already-low</link><description>NCS 2.3.0 
 nrf5340dk_nrf5340_cpuapp_ns 
 Using SPIS2 to communicate with another processor, using zephyr&amp;#39;s spi_transceive interface. 
 My application requires bidirectional communication between 2 processors over an SPI bus. The nrf5340 has been designated</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Sep 2023 14:24:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103798/is-it-possible-to-start-spis-after-csn-is-already-low" /><item><title>RE: Is it possible to start SPIS after CSN is already low?</title><link>https://devzone.nordicsemi.com/thread/446483?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2023 14:24:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e707c3f7-e14a-4765-82e0-07f796c27e33</guid><dc:creator>Jared</dc:creator><description>[quote user="anthony.asterisk"]&lt;p&gt; This means that a dummy/empty SPI slave buffer must always initially be read out, and only then the SPI slave can reload with the newly generated payload.&lt;/p&gt;
&lt;p&gt;In short, my motivation to wait for the CSN to trigger spi_transceive is so that I can determine at the latest possible moment if the slave has a payload to send back to the master.&lt;/p&gt;[/quote]
&lt;p&gt;I see, unfortunately, I don&amp;#39;t think there is any &amp;quot;solution&amp;quot; to this as this is a result of our design choice for SPIS peripheral. At least in the case that you use our drivers ( which we recommend &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt; )&lt;/p&gt;
&lt;p&gt;However, the semaphore handling doesn&amp;#39;t restrict you to update the RX and TX pointers to only when you have it, you should be able to do it regardless. It will only tell you when it&amp;#39;s safe, naturally our drivers use this semaphore to update the RX and TX pointers, but you should be able to make your own driver that doesn&amp;#39;t follow this. Of course, you risk corrupted data being sent if you do this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/spis.html?cp=4_0_0_6_30_3#semaphore_abk_lbf_wr"&gt;Documentation&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1695046994991v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is it possible to start SPIS after CSN is already low?</title><link>https://devzone.nordicsemi.com/thread/446341?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 16:19:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80f92929-a561-4aed-b46a-711610812a4c</guid><dc:creator>Anthony Ambuehl</dc:creator><description>&lt;p&gt;Since the only indication that the SPI master will soon start a SPI transaction is the CSN,&amp;nbsp; and the SPI master can generate a payload to send at any time, therefore&amp;nbsp;I must immediately start the spi_transceive operation.&amp;nbsp; After I start the spi_transceive operation, if an asynchronous SPI slave payload is generated, I cannot insert the new payload into the SPIS since the spi_transceive has already started.&amp;nbsp; This means that a dummy/empty SPI slave buffer must always initially be read out, and only then the SPI slave can reload with the newly generated payload.&lt;/p&gt;
&lt;p&gt;In short, my motivation to wait for the CSN to trigger spi_transceive is so that I can determine at the latest possible moment if the slave has a payload to send back to the master.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is it possible to start SPIS after CSN is already low?</title><link>https://devzone.nordicsemi.com/thread/446250?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 11:40:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbda686f-c0c2-4ef5-9e8c-09dc7f99b404</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""].&amp;nbsp; However during testing I find that the spi_transceive operation if started after CSN is already low does not start until after CSN goes high and low again.[/quote]
&lt;p&gt;Is any data clocked out in this case? What is the state of the MISO?&lt;/p&gt;
&lt;p&gt;I think the issue is that the CPU can&amp;#39;t set the TX or RX buffer while CSN is low because it doesn&amp;#39;t have the semaphore. If can first update the RX and TX pointers when it acquires a semaphore after the CSN signal goes high.&amp;nbsp;&lt;/p&gt;
[quote user=""]Since the SPIS spi_transceive operation is blocking until completion, I was hoping to delay calling spi_transceive until an ISR detects that CSN has gone low.&amp;nbsp;[/quote]
&lt;p&gt;But first, can you elaborate a bit more on your motivation for doing this?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrfx &lt;a href="https://infocenter.nordicsemi.com/topic/drivers_nrfx_v3.1.0/group__nrf__spis.html?cp=10_0_3_0_38"&gt;SPIS&lt;/a&gt; driver use a callback handler so that driver API shouldn&amp;#39;t be blocking, I&amp;#39;m not that familiar with the Zephyr SPIS API.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>