<?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>NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103536/nrf5340-spis-is-it-possible-to-update-tx-data-during-a-transceive-operation-based-on-received-data</link><description>I&amp;#39;m working with Zephyr using NCS 2.3.0. The boards include nrf5340 and nrf9160. 
 Project lead has specified that the nrt5340 shall operate as a SPI slave to the nrf9160. The communication protocol calls for validating the received data on the fly as</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Sep 2023 16:23:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103536/nrf5340-spis-is-it-possible-to-update-tx-data-during-a-transceive-operation-based-on-received-data" /><item><title>RE: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/446343?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 16:23:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dde2ad9-63a0-42e5-b155-ab3b658fd3c4</guid><dc:creator>Anthony Ambuehl</dc:creator><description>&lt;p&gt;Once the pointers/buffers have been set and the CSN goes low I believe it is not possible to change the pointers due to the locking semaphore in the hardware.&amp;nbsp; &amp;nbsp;While it might be possible to update the RAM the txptr will reach later in the transmission, this seems like a very tricky and failure prone approach.&amp;nbsp; I will ask for the design to be changed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/445246?ContentTypeID=1</link><pubDate>Sat, 09 Sep 2023 21:48:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a668f41-e14a-49f3-b1b2-cc37e0481793</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;I strongly suspect that there is a hardware fifo in place that would read the following byte too soon - it should latch it during the transmission of the previous byte. Keep in mind that you need the first bit &lt;em&gt;ready&lt;/em&gt; very soon at full speed, thus the RAM access has to be well in advance.&lt;/p&gt;
&lt;p&gt;You are free to try your luck.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/445245?ContentTypeID=1</link><pubDate>Sat, 09 Sep 2023 20:56:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23b43736-1d30-4fa2-b37e-97c9ac1d07e2</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Yes the hardware semaphore in the nRF5340 SPIS is a nice feature, but no it does not preclude the scheme I suggested for changing the last byte in the Tx buffer prior to transmission. From Product Spec v1.3 (latest to hand):&lt;/p&gt;
&lt;p&gt;&lt;em&gt; Note: The semaphore mechanism does not, at any time, prevent the CPU from performing read or write access to the RXD.PTR register, the TXD.PTR registers, or the RAM that these pointers are pointing to. The semaphore is only telling when these can be updated by the CPU so that safe sharing is achieved.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I agree there is risk here if the timing of&amp;nbsp;&lt;em&gt;&amp;lt;Twiddle Thumbs with no clocks or data&amp;gt;&lt;/em&gt;&amp;nbsp;is too short, but that&amp;#39;s up to the user. A protocol redesign may be the recommended path, but I like my idea :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/445231?ContentTypeID=1</link><pubDate>Sat, 09 Sep 2023 07:22:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3be0c54-c869-4032-81f3-048aa895459f</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;The NRF SPIS peripherial does not allow changing bytes during a transaction (CS=low). Read the PS for details, but this is a basic requirement that allows the SPIS to run at a relatively high speed.&lt;/p&gt;
&lt;p&gt;I strongly recommend a protocol redesign with this hardware limitation in mind.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/445226?ContentTypeID=1</link><pubDate>Fri, 08 Sep 2023 21:24:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a81bdeb-c777-4707-8af3-82458b5bb530</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Yes, but not quite as you&amp;nbsp;may be thinking. Use a single SPI transaction thus:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;lt;CS low&amp;gt;&amp;lt;Tx: Length byte&amp;gt;&amp;lt;Tx:&amp;nbsp;Length Data Bytes&amp;gt;&amp;lt;Twiddle Thumbs with no clocks or data&amp;gt;&amp;lt;Tx:&amp;nbsp;Dummy Byte to read&amp;nbsp;Ack/Nack&amp;gt;&amp;lt;CS High&amp;gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The Master actually uses two transactions, length bytes and a single byte, separated by a long enough interval to allow the Slave to calculate the Ack/Nak and all within a single CS such that the slave only sees a single SPI transaction with a pause in clocking, perfectly acceptable. The Slave can change any byte in the queue for response up until the receive clock edge changes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/445222?ContentTypeID=1</link><pubDate>Fri, 08 Sep 2023 20:55:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:992a1107-74cc-4d78-add7-58615efa45f8</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Read the SPIS chapter in the PS that describes how the SPI slave peripherial works. It is &lt;strong&gt;impossible&lt;/strong&gt; for the CPU to change bytes in a running SPIS transaction, you can only change the &lt;em&gt;next&lt;/em&gt; one.&lt;/p&gt;
&lt;p&gt;Your protocol design won&amp;#39;t work with an MCU as SPI slave. These need noteworthy processing time in order to decide if a packed was valid or not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This SPI slave protocol would require an asic or FPGA in order to meet the &amp;lt;1&amp;micro;s timing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/445210?ContentTypeID=1</link><pubDate>Fri, 08 Sep 2023 18:41:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfa11d0c-b9f1-4a3a-8248-748bc2420207</guid><dc:creator>Anthony Ambuehl</dc:creator><description>&lt;p&gt;It would be helpful to start, if you could provide a working example for the nrf5340 operating as a SPI Slave within zephyr on NCS 2.3.0.&amp;nbsp; The examples I have found are very old and don&amp;#39;t use the pinctrl setup.&amp;nbsp; So far I have not even seen the build attempt to compile the nrfx_spis code.&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: NRF5340 SPIS is it possible to update tx data during a transceive operation based on received data?</title><link>https://devzone.nordicsemi.com/thread/444987?ContentTypeID=1</link><pubDate>Thu, 07 Sep 2023 15:05:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76c01536-9088-4617-a287-a55ce6fbc9bf</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hello Anthony,&lt;/p&gt;
&lt;p&gt;Thank you for contacting DevZone at NordicSemi.&lt;br /&gt;I am not fully sure about your requirements, and whether it could be done or not, but let us start by looking at the documentation.&lt;/p&gt;
&lt;p&gt;Some SoC support legacy mode spi and some only use the Spi with EasyDma.&lt;br /&gt;As you are using nrf5340, we see that this SoC (App core) only supports SPI M/S with EasyDma (upto 5 instances).&lt;br /&gt;Next, yes, the UARTE reception generates RXDRDY (receiver ready) event for each byte received. But that is not the case for SPIS. However, SPIS uses RXD.PRT (receive buffer pointer) and generates ENDRX event when RX buffer is filled. We have RXD.MAXCNT register that specifies the maximum number of bytes the SPI slave can receive in one granted transaction. &lt;br /&gt;Maximum SPIS clock frequency can be 8MHz.&lt;/p&gt;
&lt;p&gt;I am not sure what suits you, but one thing can be that you configure receiver buffer of size 1, and then after reception of each byte, you will get the ENDRX event as you were looking to have something similar like the UARTE receiver ready event.&lt;br /&gt;Another way can be that, as the received data starts with length field (a number n) and then n-Bytes of data, and another byte; if we consider number n (like 64, or 128) to be 1-byte, then you are actually transmitting n+2 bytes of data. After you receive n+2 byte of data, you can analyze the last byte and then validate the transmission.&lt;/p&gt;
&lt;p&gt;In the Zephyr SPI Driver API, the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;spi_transceive&lt;/span&gt; function uses &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;rx_bufs&lt;/span&gt; pointer that is of type &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;spi_buf_set&lt;/span&gt;. You can set the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;count&lt;/span&gt; variable of this structure to 1 to say that you want 1 byte register buffer.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>