<?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>there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71898/there-are-10us-delay-between-nrf5340-spi-write-and-read-sequence</link><description>hi professor, 
 I use the zephyr spi driver to control spi nand flash.I want to send two bytes and read 3 bytes. But between write and read time sequence there are 10us delay. 
 As shown as the blow picture,the first 16 clocks to write, after Interval</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 05 Mar 2021 14:38:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71898/there-are-10us-delay-between-nrf5340-spi-write-and-read-sequence" /><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/298135?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 14:38:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac6a7926-9bd2-42d8-9a63-d34eb4f1ea60</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Check out the note given here:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf5340.html#working-with-nrf53-series"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf5340.html#working-with-nrf53-series&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;See the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.0/nrf/index.html"&gt;nRF Connect SDK v1.4.0 documentation&lt;/a&gt;&amp;nbsp;for the last release supporting the nRF5340 PDK.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Check out NCS v1.4.0 for nrf5340 pdk&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/298125?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 14:21:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a626a111-0b52-427e-9a36-d76a2957c5f7</guid><dc:creator>sunnyyang</dc:creator><description>&lt;p&gt;hi simon,&lt;/p&gt;
&lt;p&gt;I use the nrfx SPI API but&amp;nbsp;error occur in code running.What causes this error？My board type is nrf5340pdk. The same code running in 5340dk is normal.What&amp;#39;s the difference between the two boards？&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1614953812738v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/297883?ContentTypeID=1</link><pubDate>Thu, 04 Mar 2021 16:39:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4776843e-097e-49f3-8ce1-47d255287259</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;You may check out this case&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/66488/using-spi-with-ppi-in-zephyr/272139#272139"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/66488/using-spi-with-ppi-in-zephyr/272139#272139&lt;/a&gt;&amp;nbsp;where a colleague has attached a sample where the nrfx SPI API is used directly&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/296991?ContentTypeID=1</link><pubDate>Mon, 01 Mar 2021 18:40:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d08beb5-4b16-4071-bbf9-8e47f9984d01</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I did some investigation today. What I did was to read the PARTID register of the adxl362 sensor using the nRF5340. That requires a write followed by a read, like you described. It took about 9.14 us between the two transactions. I used the&amp;nbsp;following code to perform the write/read at once:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int adxl362_read_reg(uint8_t reg_addr, void *data, size_t length)
{
	uint8_t access[2] = { ADXL362_READ_REG, reg_addr };
	const struct spi_buf buf[2] = {
		{
			.buf = access,
			.len = 2
		},
		{
			.buf = data,
			.len = length
		}
	};
	struct spi_buf_set tx = {
		.buffers = buf,
	};

	const struct spi_buf_set rx = {
			.buffers = buf,
			.count = 2
		};

	tx.count = 1;

	return spi_transceive(spi_dev, &amp;amp;spi_cfg, &amp;amp;tx, &amp;amp;rx);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I triggered a GPIO when &lt;span&gt;NRF_SPIM_EVENT_END happened (called END_EVENT in the image)&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/8f013ea950f41bf69b18bf688bfb0dd80a3fdc44/nrfx/drivers/src/nrfx_spim.c#L768"&gt;https://github.com/nrfconnect/sdk-hal_nordic/blob/8f013ea950f41bf69b18bf688bfb0dd80a3fdc44/nrfx/drivers/src/nrfx_spim.c#L768&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I also triggered a GPIO when the&amp;nbsp;NRF_SPIM_TASK_START was triggered (called START_TASK in the image)&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/8f013ea950f41bf69b18bf688bfb0dd80a3fdc44/nrfx/drivers/src/nrfx_spim.c#L603"&gt;https://github.com/nrfconnect/sdk-hal_nordic/blob/8f013ea950f41bf69b18bf688bfb0dd80a3fdc44/nrfx/drivers/src/nrfx_spim.c#L603&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is the result:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/2000x1000/__key/communityserver-discussions-components-files/4/7888.pastedimage1614873613692v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, there is some delay betwwen the task NRF_SPIM_TASK_START and the begining of the transaction. This task is sent direcly to the spi, so the this delay is due to the SPI peripheral.&lt;/p&gt;
&lt;p&gt;You can also see that there is a delay between the first transaction and the first&amp;nbsp; NRF_SPIM_EVENT_END event received, that delay is also due to the SPI peripheral, since it will generate this event after the ENDRX and ENDTX events are generated, read more about it here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf5340%2Fspim.html&amp;amp;cp=3_0_0_6_29_0&amp;amp;anchor=concept_lhv_fx2_wr"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf5340%2Fspim.html&amp;amp;cp=3_0_0_6_29_0&amp;amp;anchor=concept_lhv_fx2_wr&lt;/a&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The delay between the first&amp;nbsp;NRF_SPIM_EVENT_END&amp;nbsp; event and the second&amp;nbsp;NRF_SPIM_TASK_START&amp;nbsp;is due to the CPU, it has a handler that receives the end event before starting the next transaction.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;I guess there is not much to do with the delay caused by the SPI. However to decrease the time caused by the CPU, you could use the NRFX API directly. I guess that will reduce the time, since there are many abstraction layers and overhead in Zephyr that may increase the time.&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/296885?ContentTypeID=1</link><pubDate>Mon, 01 Mar 2021 14:15:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ce11e30-e3ad-40c3-b2d3-8b3086fccb0b</guid><dc:creator>sunnyyang</dc:creator><description>&lt;p&gt;hi simon,&lt;/p&gt;
&lt;p&gt;Is there any progress on this issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/296325?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 14:56:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4c2fe2e-7770-4fcf-b245-961edd544602</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I tested this out myself and got about the same result as you. I tried to write to a register of an adxl362 and then read it, and checked the lines on a logic analyzer.&lt;/p&gt;
&lt;p&gt;I guess around 10us is&amp;nbsp;what the CPU needs in order to execute the necessary instructions in order to set up and execute and spi read.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll take a closer look at it tomorrow and try to give you a more detailed answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/296285?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 13:48:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03b4f726-c848-45db-8baa-5a65f8b8e81e</guid><dc:creator>sunnyyang</dc:creator><description>&lt;p&gt;hi simon，&lt;/p&gt;
&lt;p&gt;Please could you advise me what I should do?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/295890?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 15:40:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7a3861a-fcb1-46cd-8fe2-c6e6596e772a</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Ah, okay. I understand. I&amp;#39;ll look into it tomorrow.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/295878?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 15:12:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41899160-862c-4ab2-bef4-57670cd4c5f4</guid><dc:creator>sunnyyang</dc:creator><description>&lt;p&gt;I want the clock to be continuous for read and write operations.Now&amp;nbsp;The interval between write and read operations is 10us.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1614093119868v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: there are 10us delay  between nrf5340 spi write and read sequence</title><link>https://devzone.nordicsemi.com/thread/295873?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 14:54:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1fe6187-33d6-460c-8165-d718ed35d5b0</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure if I understand this question: &amp;quot;&lt;span&gt;How can I make the write and read sequence continue?&lt;/span&gt;&amp;quot; Can you elaborate?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>