<?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 RAW Timing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66565/spi-raw-timing</link><description>These questions are in the context of using an nRF52840 in a serialization application. But I don&amp;#39;t believe this will impact the information I am trying to understand. The following questions are in the context of using an nRF52840 for both the application</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Sep 2020 17:25:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66565/spi-raw-timing" /><item><title>RE: SPI RAW Timing</title><link>https://devzone.nordicsemi.com/thread/272375?ContentTypeID=1</link><pubDate>Tue, 29 Sep 2020 17:25:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5086ecc8-2d9d-4aca-87cf-bc7bc1535d6f</guid><dc:creator>Jeff4BLE</dc:creator><description>&lt;p&gt;Hi Jørgen,&lt;/p&gt;
&lt;p&gt;Thank you for your investigation and thorough response.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Jeff&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI RAW Timing</title><link>https://devzone.nordicsemi.com/thread/272374?ContentTypeID=1</link><pubDate>Tue, 29 Sep 2020 15:45:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fde4d4d8-4503-40bc-8f19-4785e96566ad</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi Jeff,&lt;/p&gt;
[quote user=""]Referring &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/ser_phy_spi_page.html"&gt;SPI RAW - packet writing&lt;/a&gt;, I have been asked what causes the approximate 10 uS delay from the end of the 2nd byte to /RDY transitioning to a high state. I assume this is simply overhead in the Slave or Master driver. What is bugging me is I am unable to determine is /RDY is responding to the /CD transition or an independent event with the slave.[/quote]
&lt;p&gt;The 10 us delay (or almost 15 us in my tests) seems to be a combination of multiple tasks:&lt;/p&gt;
&lt;p&gt;From last negedge on CLK to END event generated by SPIM peripheral (~1 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/0636.CLK_5F00_to_5F00_END_5F00_EVT.png" /&gt;&lt;/p&gt;
&lt;p&gt;From END event until CSN is deasserted (~13 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/0640.END_5F00_EVT_5F00_to_5F00_CSN.png" /&gt;&lt;/p&gt;
&lt;p&gt;From CSN is deasserted until RDY is deasserted (~0.3 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/4834.CSN_5F00_to_5F00_RDY.png" /&gt;&lt;/p&gt;
&lt;p&gt;The RDY signal is controlled by a PPI channel in the SPI slave transport layer:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void spi_slave_ppi_init(void)
{
    uint32_t rdy_task = nrf_drv_gpiote_out_task_addr_get(m_spi_slave_raw_config.pin_rdy);
    //Configure PPI channel  to clear /RDY line
    NRF_PPI-&amp;gt;CH[m_spi_slave_raw_config.ppi_rdy_ch].EEP = (uint32_t)(&amp;amp;SPI_SLAVE_REG-&amp;gt;EVENTS_END);
    NRF_PPI-&amp;gt;CH[m_spi_slave_raw_config.ppi_rdy_ch].TEP = rdy_task;

    //this works only for channels 0..15 - but soft device is using 8-15 anyway
    NRF_PPI-&amp;gt;CHEN |= (1 &amp;lt;&amp;lt; m_spi_slave_raw_config.ppi_rdy_ch);
    return;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It will be toggled when the END event is generated by the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/spis.html#concept_abk_lbf_wr"&gt;SPIS peripheral&lt;/a&gt;. This happens shortly after CSN is deassert by the SPI master:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;&lt;span&gt;When a granted transaction is completed and CSN goes high, the SPI slave will automatically release the semaphore and generate the END event.&amp;quot;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;CSN is handled purely in software in the SPI driver used by the SPI master, only SPIM3 supports hardware control of SS/CSN pin. The main cause of the delay from the END event until CSN is deasserted seems to be the latency before the interrupt handler is triggered. I tried to reduce this delay by enabling constant latency mode, starting the HFCLK, and not putting the chip to sleep, but the only thing that helped was to run the debugger when testing.&lt;/p&gt;
[quote user=""]The customer payloads will vary in size and some will exceed 255 bytes. Can you point me to a reference as to how CS and RDY would or would not transition during a 770-byte data payload. To use the sterilization application, I assume that the application would imagine sending packets of 255 - 255- 255 - 5 in separate transactions? And CS and RDY would have the same timing as the SPI RAW - packet writing timing diagrams. But if one wrote an independent application, where the gold was to send one block of 770 bytes I suspect that CS will remain active for the whole transaction and READY would remain asserted as long as there is enough memory to store the receive data?[/quote]
&lt;p&gt;I could not find any documentation describing this, but I checked with a logic analyzer that the CSN/RDY pins are toggled between each transfer of long packets:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2318.longpackets_5F00_delay.png" /&gt;&lt;/p&gt;
&lt;p&gt;The serialization libraries was written when only nRF52832 chip was available. This chip had a limitation of 255 bytes length for most EasyDMA peripherals (SPIM/SPIS/TWIM/UARTE). I believe that the 255 byte packet limitation is originating from this. As mentioned above, the SPIS peripheral uses the CSN pin to determine when the transfer is ended. If the CSN pin was asserted during the whole transfer, the SPIS peripheral will not know when to prepare a new buffer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nRF52840 has support for larger buffers (up to 65635 bytes) for both SPIM and SPIS, but unfortunately this is not implemented in the serialization libraries. Adding support for longer transfers would require rewriting the whole nrf_drv_spi/spis drivers (which uses uint8_t variables for the length parameters), or replace the drivers with nrfx variants. As far as I know, there is no plans to do this.&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>