<?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>Separate SPIM command to Rx and Tx</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59685/separate-spim-command-to-rx-and-tx</link><description>Hi 
 I using nRF52840-DK with 64 Mb external flash memory. 
 I&amp;#39;m using SPI interface for read / write command with the external flash. 
 When I&amp;#39;m using single command for write and read it working well 
 
 but when I&amp;#39;m trying to separate the commands</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Apr 2020 09:13:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59685/separate-spim-command-to-rx-and-tx" /><item><title>RE: Separate SPIM command to Rx and Tx</title><link>https://devzone.nordicsemi.com/thread/242877?ContentTypeID=1</link><pubDate>Wed, 01 Apr 2020 09:13:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fcf93cb-29ec-4bb8-8c3b-38354baa07d9</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;No problem at all, I am happy to help.&lt;br /&gt;&lt;br /&gt;Great, Looking forward to hearing if this resolves your issue!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Separate SPIM command to Rx and Tx</title><link>https://devzone.nordicsemi.com/thread/242853?ContentTypeID=1</link><pubDate>Wed, 01 Apr 2020 08:26:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7de2fed-c1b7-412e-ac63-d862dffa3116</guid><dc:creator>shai.c</dc:creator><description>&lt;p&gt;Thanks for your answer!&lt;/p&gt;
&lt;p&gt;I will test it again and will update&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Separate SPIM command to Rx and Tx</title><link>https://devzone.nordicsemi.com/thread/242850?ContentTypeID=1</link><pubDate>Wed, 01 Apr 2020 08:21:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5ccdab9-08ca-4aa3-83e8-6d6f1654d2bf</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Shai,&lt;br /&gt;&lt;br /&gt;Sorry for my late reply.&lt;/p&gt;
[quote user="shai.c"]in case I want to read more than 255 bytes it limits me to send each time read command[/quote]
&lt;p&gt;Are you here referring to the RXD.MAXCNT limitation of the nRF52832?&lt;br /&gt;&lt;br /&gt;The nRF52840 DK, which you have tagged your post with, supports 16-bit MAXCNT, which in turn does not limit you to only receiving 255 bytes. The documentation for the SPIM MAXCNT registers of the nRF52840 can be seen &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fspim.html&amp;amp;anchor=register.RXD.MAXCNT"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So, if you set the MAXCNT sufficiently high enough you may receive the required number of bytes to your RAM, and then handle them as you would normally - instead of having to divide up your reads and handling.&lt;br /&gt;&lt;br /&gt;Could this resolve your issue?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Separate SPIM command to Rx and Tx</title><link>https://devzone.nordicsemi.com/thread/242828?ContentTypeID=1</link><pubDate>Wed, 01 Apr 2020 06:00:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dc35534-dee7-4f13-8925-0aefcde7b88a</guid><dc:creator>shai.c</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Karl,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Any suggestions?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/members/karl-ylvisaker"&gt;Karl Ylvisaker&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Separate SPIM command to Rx and Tx</title><link>https://devzone.nordicsemi.com/thread/242523?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 17:15:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aec228e5-ea02-4430-bb15-2d49a4f2b3cd</guid><dc:creator>shai.c</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Thanks for your answer.&lt;/p&gt;
&lt;p&gt;I want to separate these commands for reading data from the flash, in case I want to read more than 255 bytes it limits me to send each time read command (like below), instead to send once the command and then read in loop the mount that was requested.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint8_t spi_tx_cmd[] = {CMD_READ, (address &amp;gt;&amp;gt; 16) &amp;amp; 0xFF, (address &amp;gt;&amp;gt; 8) &amp;amp; 0xFF, (address &amp;gt;&amp;gt; 0) &amp;amp; 0xFF};
uint8_t spi_rx_response[255];
nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(spi_tx_cmd, sizeof(spi_tx_cmd), spi_rx_response, sizeof(spi_rx_response);
nrfx_spim_xfer(&amp;amp;m_spim_mx, &amp;amp;xfer_desc, 0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;my idea was to use somethink like that:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void flash_read(uint32_t address, uint8_t *data_ptr, uint32_t data_length)
{
	uint8_t spi_tx_cmd[] = {CMD_READ, (address &amp;gt;&amp;gt; 16) &amp;amp; 0xFF, (address &amp;gt;&amp;gt; 8) &amp;amp; 0xFF, (address &amp;gt;&amp;gt; 0) &amp;amp; 0xFF};

	nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_RX(spi_tx_cmd, sizeof(spi_tx_cmd));
	nrfx_spim_xfer(&amp;amp;m_spim_mx, &amp;amp;xfer_desc, 0);

	while(data_length &amp;gt; 255)
	{
		nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_RX(data_ptr, 255);
		nrfx_spim_xfer(&amp;amp;m_spim_mx, &amp;amp;xfer_desc, 0);
		data_ptr += 255;
		data_length -= 255;
	}
	nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_RX(data_ptr, data_length);
	nrfx_spim_xfer(&amp;amp;m_spim_mx, &amp;amp;xfer_desc, 0);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Separate SPIM command to Rx and Tx</title><link>https://devzone.nordicsemi.com/thread/242508?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 16:00:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8dd55fd-b5ad-4037-9412-5dd839702789</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Could you elaborate why you would like to do RX and TX in separate read write commands?&amp;nbsp;Since&amp;nbsp;SPI is full-duplex communication happens both ways&amp;nbsp;simultaneously.&lt;br /&gt;Have you seen the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrfx__spim.html&amp;amp;anchor=ga727a6df44fa2f3f6b1999340a8e52430"&gt;SPIM API Reference&lt;/a&gt; for the nrfx_spim_xfer_rx and&amp;nbsp;&lt;span&gt;nrfx_spim_xfer_tx? These macros just set up descriptors for a single transfer instance and are meant for internal use only. My suggestion would be to use the nrfx_spim_xfer functions for doing transfers, like in your first code snippet.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Karl&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>