<?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 delays between writes</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76517/spi-delays-between-writes</link><description>I am currently using the 17.0.2 SDK to develop some code on the nrf52832 which involves streaming data via SPI to an external flash. I need to stream this data at a ~50KHz rate. The data to the flash consists of the write command (8bits) followed by the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Jul 2021 12:50:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76517/spi-delays-between-writes" /><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/318223?ContentTypeID=1</link><pubDate>Thu, 01 Jul 2021 12:50:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d88499f5-16b1-41e3-8105-88a04d96cc13</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi Tim,&lt;/p&gt;
&lt;p&gt;The GPIO peripheral run of 16MHz (this is fixed), however depending on how the code is written and compiled, and there is an OS running here also, then you likely will not be able to get this high speed. Though, 2us, was a bit slower than I would expect yes.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/317552?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 16:50:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37fcc921-e890-4f76-80f7-6f1dbc28ef2a</guid><dc:creator>ProtonTim</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;Thank you for the answer.&amp;nbsp; I understand your explanation.&amp;nbsp; Fortunately, running the SPI in blocking mode gets me just under my bandwidth limit, so I should be good to go.&amp;nbsp; However, I do have one additional question.&amp;nbsp; In my trying to optimize the CE assertion timing I put a bunch of set/clear commands together to see what the maximum GPIO toggle rate was.&amp;nbsp; If I remember right it was about 2uS per transition.&amp;nbsp; This seemed slower than I expected.&amp;nbsp; I am very new to the ARM architecture so my question might be ignorant, but I was wondering if there was a way to get faster IO response by changing the peripheral clock speed to the IO or by some other means.&lt;/p&gt;
&lt;p&gt;Thanks for your help,&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/317488?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 12:51:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87e5861c-efbe-4481-a508-1b1a947d1c3a</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi Tim,&lt;/p&gt;
&lt;p&gt;There is no direct hardware control of the CE pin when using SPI, so the application will need to handle the CE pin manually, typically there will be some delays due to the way it&amp;#39;s implemented. E.g. there will interrupt latencies here du to possible wakeup before and after the SPI transfer, and possible delay due to the SoC framework if the softdevice is enabled and need to forward the interrupt to the application, not to mention some delay due to code execution handling the interrupt. Adding these up you may experience several us of delay before and after SPI transcation and CE pin.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The only real way to reduce this is to use PPI to handle the CE pin and SPI transcation. There is a discussion in this case how this can be done:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/13523/ppi-to-spim-task-how-to"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/13523/ppi-to-spim-task-how-to&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Alternatively use the nRF52840 which have an SPIM3 interface with CE handling in hardware.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/317317?ContentTypeID=1</link><pubDate>Fri, 25 Jun 2021 16:50:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a4e6609-7d63-4b0b-a5a2-9142492f8474</guid><dc:creator>ProtonTim</dc:creator><description>&lt;p&gt;Simon,&lt;/p&gt;
&lt;p&gt;Since I didn&amp;#39;t hear back from you I dug into the source code a bit and found that if I pass a NULL for the interrupt handler it will run as blocking code.&amp;nbsp; Running the code in blocking mode provides about a 15% speed increase, but the delay between /CE being asserted and data coming out, and the delay between data finishing and /CE being deasertted are still way to long.&amp;nbsp; Do you know why there is such latency?&amp;nbsp; Is there a way to remove that latency?&amp;nbsp; I am under a bit of time pressure so a prompt response would be greatly appreciated.&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/317022?ContentTypeID=1</link><pubDate>Thu, 24 Jun 2021 13:25:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98544a1e-4cb3-4d58-a304-807b4414f415</guid><dc:creator>ProtonTim</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;I am having trouble seeing any difference between what you are recommending and what I am currently doing.&amp;nbsp; I have always had #include&amp;nbsp;&lt;span&gt;nrf_drv_spi.h&amp;quot; as part of my file and I call the&amp;nbsp;nrf_drv_spi_transfer just as it says in the link you provided (see line below).&amp;nbsp; It looks to me like I have been doing what you said and what is indicated in the link but this is what is giving me the long delays.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;APP_ERROR_CHECK(nrf_drv_spi_transfer(spi_inst, tx_buffer, tx_length, rx_buffer, rx_length));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Can you please tell me what I might be missing?&lt;/p&gt;
&lt;p&gt;One additional note:&amp;nbsp; I think it is important to point out the that the delays that I need to get rid are the delay between when CE is asserted and when the data transmission starts, and the delay between when the data transmission has ended and CE is deasserted. These delays can be seen by referring to the second of the timing pictures at the start of this thread.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/316936?ContentTypeID=1</link><pubDate>Thu, 24 Jun 2021 10:19:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3415d6a-285b-4bb7-bbe9-f7d4a29fa7af</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;He used the api&amp;nbsp;&lt;em&gt;nRF5_SDK_17.0.2_d674dde/integration/nrfx/legacy/nrf_drv_spi.h&lt;/em&gt;, add&amp;nbsp;&lt;code&gt;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;quot;nrf_drv_spi.h&amp;quot;&lt;/code&gt; at the top of you file. Also check out the the driver description of SPI Master in the documentation:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fhardware_driver_spi_master.html&amp;amp;cp=8_1_2_0_13"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fhardware_driver_spi_master.html&amp;amp;cp=8_1_2_0_13&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Simon&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/316536?ContentTypeID=1</link><pubDate>Tue, 22 Jun 2021 15:21:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:663510b4-5d6d-4536-b156-4dd278307ae8</guid><dc:creator>ProtonTim</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;In the referenced thread he mentioned he used the&amp;nbsp;&lt;span&gt;standard spi transfer api to get faster time between transfers.&amp;nbsp; Could you point me to where I might find out more about that api and how it is different that what I have implemented&amp;nbsp;using the example code?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Tim&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI delays between writes</title><link>https://devzone.nordicsemi.com/thread/316409?ContentTypeID=1</link><pubDate>Tue, 22 Jun 2021 08:40:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:942f60f0-f0aa-465e-a533-571894518012</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;This thread may be useful to take a look at:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/56180/reduce-time-between-spi-transfers"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/56180/reduce-time-between-spi-transfers&lt;/a&gt;, where also a piece of code is attached that demonstrates how to achieve a low delay between the SPI transfers.&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></channel></rss>