<?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>How to receive an unknown amount of data on SPI?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3452/how-to-receive-an-unknown-amount-of-data-on-spi</link><description>Hi everybody! 
 I&amp;#39;ve plugged my NRF51422 as a slave on a STM32 through a SPI bus. I would like to be able to send to the NRF an unknown amount of data. I also need to read the bytes as they arrived in order to know how to handle the next ones and finally</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Aug 2014 11:07:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3452/how-to-receive-an-unknown-amount-of-data-on-spi" /><item><title>RE: How to receive an unknown amount of data on SPI?</title><link>https://devzone.nordicsemi.com/thread/12501?ContentTypeID=1</link><pubDate>Fri, 15 Aug 2014 11:07:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f87c310c-53b5-45a5-a39d-0c094c2701be</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Harold&lt;/p&gt;
&lt;p&gt;The behavior is that when CSN line goes high, that indicates end of the SPI transaction and that triggers the SPIS-&amp;gt;END event. You should therefore make the SPI master set the CSN line high when the transaction is finished. You must also define an upper bound to the data amount sent in each transaction, and specify the buffer size of the SPIS with this upper bound by configuring the SPIS-&amp;gt;MAXRX register. When the CSN is set high and the transaction ends, SPIS-&amp;gt;AMOUNTRX register tells how many bytes were received in the last transaction.&lt;/p&gt;
&lt;p&gt;Is it not possible to let the STM32 set the CSN high when it is finished transmitting, or otherwise do that periodically? On the nRF51 SPI master, the application directly controls the CSN signal which is connected to a GPIO pin. Is this not similar on STM32?&lt;/p&gt;
&lt;p&gt;Have you looked at the SPI slave example in the SDK that uses the spi_slave library? There is also a companion SPI master example, which migh be useful if you are able to connect two boards together. &lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/6.0.0/s110/html/a00049.html"&gt;Here&lt;/a&gt; is brief documentation for the example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>