<?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>SPI Overhead</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72747/spi-overhead</link><description>Hi, 
 -I have a custom board using nrf 52832 and I have interfaced sensor using an SPI interface. -I am using SDK 15.2.0 and SPI driver. -I am collecting raw data and send them serially. 
 =============================================================</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Mar 2021 11:50:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72747/spi-overhead" /><item><title>RE: SPI Overhead</title><link>https://devzone.nordicsemi.com/thread/302120?ContentTypeID=1</link><pubDate>Fri, 26 Mar 2021 11:50:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4f5ebe3-e103-49ed-8fb3-512146a23e16</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You can use the HAL function:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__spi__hal.html#ga99ba33ba4732053a33db9aa445c82cb8"&gt;nrf_spi_event_clear&lt;/a&gt;(), where you pass the SPI instance and the event, or you can clear the register manually:&lt;/p&gt;
&lt;p&gt;NRF_SPI(M)x-&amp;gt;EVENTS_READY = 0, where x is the SPI instance, and M is included if you are using the SPIM peripheral with EasyDMA support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Overhead</title><link>https://devzone.nordicsemi.com/thread/302107?ContentTypeID=1</link><pubDate>Fri, 26 Mar 2021 10:40:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3271252c-b0de-4097-a207-1f75dcec0555</guid><dc:creator>pd@learner</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have one more question.&lt;/p&gt;
&lt;p&gt;How to clear&amp;nbsp;&lt;span&gt;NRF_SPI_EVENT_READY manually?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Overhead</title><link>https://devzone.nordicsemi.com/thread/301379?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2021 10:28:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3b68a22-5d52-4e3e-add8-d90f6af62d4e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;What exactly do you mean by &amp;quot;&lt;span&gt;every time I get the first value in all 6 registers.&amp;quot; Do you mean that the receive buffer is filled with the same byte?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Have you checked the SPI lines with a logic analyzer, to see if the sensor outputs the expected data?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The code you have posted will write two bytes and read 6 bytes, but note that the receive buffer will be filled while the two first bytes are written. This means that you will only receive 4 bytes&amp;nbsp;&lt;em&gt;after&lt;/em&gt; the write is done to the sensor. Normally, the sensor will not output valid data for bytes where the register address is written, so you need to increase the read buffer to 8 bytes if you want to receive 6 bytes after the write command is completed.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Overhead</title><link>https://devzone.nordicsemi.com/thread/301101?ContentTypeID=1</link><pubDate>Mon, 22 Mar 2021 04:38:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f199db3-1265-41ac-92ec-140362a6f1e1</guid><dc:creator>pd@learner</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for clarification&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;&lt;span&gt;want to read multiple bytes at a time i.e 6 bytes&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I m trying to read as follows but every time I get the first value in all 6 registers.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;void spi_burst_read_reg()&lt;br /&gt;{&lt;br /&gt; nrf_drv_spi_xfer_desc_t spd; &lt;br /&gt; t_tx_data[0]= LIS2DH_OUT_X_L|0x80; //read bit&lt;br /&gt;&lt;br /&gt; memset(t_rx_data, 0, 6);&lt;br /&gt; &lt;br /&gt; spi_xfer_done = false;&lt;br /&gt; memset(t_rx_data, 0, 6);&lt;br /&gt; &lt;br /&gt; spd.p_tx_buffer = t_tx_data;&lt;br /&gt; spd.tx_length = 2;&lt;br /&gt; spd.p_rx_buffer = t_rx_data;&lt;br /&gt; spd.rx_length = 6;&lt;br /&gt; APP_ERROR_CHECK(nrf_drv_spi_xfer(&amp;amp;spi, &amp;amp;spd, NRF_DRV_SPI_FLAG_TX_POSTINC));&lt;br /&gt; &lt;br /&gt; while (!spi_xfer_done)&lt;br /&gt; {&lt;br /&gt; __WFE();&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; Can you tell me how to read it using the nrf spi driver.?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Overhead</title><link>https://devzone.nordicsemi.com/thread/299857?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 14:52:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75bb498c-0c6a-4ae1-88eb-d6d173a7ebda</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is some small overhead in starting and completing the transfer, but the transfer itself does not have any overhead.&lt;/p&gt;
&lt;p&gt;I did a quick test with a logic analyzer to show you the timings in the default SPI master example in the SDK, with frequency increased to 4 MHz:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/spi_5F00_timing_5F00_sleep.png" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the transfer of 12 bytes takes ~24 us, which correspond with the calculations (8 bits/byte * 12 bytes * (1/4MHz) = 24 us).&lt;/p&gt;
&lt;p&gt;The toggling of SS signal is handled in SW by transfer start function and interrupt handler triggered by the END event. This is about 40 us, giving a total overhead of ~16 us.&lt;/p&gt;
&lt;p&gt;The timing overhead will depend on the optimization of the code and what state the chip is in when the interrupt is generated. If I remove the sleep function from the example (__WFE()), the overhead is reduced to about 5.5 us:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/spi_5F00_timing_5F00_no_5F00_sleep.png" /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>