<?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>Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56180/reduce-time-between-spi-transfers</link><description>Dear all, 
 
 I am using a DK with the NRF52832 to drive a 32-bit DAC through SPI @ 8 MHz. I use a solution based on the peripheral/spi example using the SDK15. 
 My goal is to change the DAC value every (say) 5 us. This is theoretically possible since</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Aug 2023 07:01:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56180/reduce-time-between-spi-transfers" /><item><title>RE: Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/thread/443282?ContentTypeID=1</link><pubDate>Mon, 28 Aug 2023 07:01:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:801ba352-2f5b-4f9e-a8e4-cde71a1e7853</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;MinhDuc,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please post your question in a new ticket instead of resurrecting this old thread. If your question is related to the content of this ticket, you can post a link to this in your new ticket.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/thread/443259?ContentTypeID=1</link><pubDate>Mon, 28 Aug 2023 00:23:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25fa4c67-7074-4fdd-bbda-9ab83a39b3e5</guid><dc:creator>MinhDuc</dc:creator><description>&lt;p&gt;Hello J&amp;oslash;rgen Holmefjord,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am following your code to send SPI with PPI to reduce as much as possible delay between each SPI transfer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried to use it in multiple&amp;nbsp;&lt;span&gt;different SPI but failed.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Please suggest how can I link multiple different SPI with PPI?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For ex:&lt;/p&gt;
&lt;p&gt;While(true)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; if (timer_handle_tick == true)&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI_1_send();&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI_2_send();&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI_3_send();&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI_4_send();&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; timer_handle_tick = false;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Best,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;MinhDuc&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/thread/229766?ContentTypeID=1</link><pubDate>Mon, 20 Jan 2020 08:36:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:884d3261-5d2f-4921-b067-2610919812c3</guid><dc:creator>Fran89</dc:creator><description>&lt;p&gt;For the time being I decided to use the standard spi transfer api.&lt;/p&gt;
&lt;p&gt;I tried linking PPI channels to the timer and the spi, but I could not successfully manage to do so. However, I believe that is the way to go when I become more time-constrained.&lt;/p&gt;
&lt;p&gt;I will open a new topic when I have doubts about that, and I think my question has been answered here.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/thread/228670?ContentTypeID=1</link><pubDate>Sat, 11 Jan 2020 12:30:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad36035a-c5a7-4c78-8d71-bea5364d06b4</guid><dc:creator>Fran89</dc:creator><description>&lt;p&gt;Hi again.&lt;/p&gt;
&lt;p&gt;This looks exactly like what I am looking for.&amp;nbsp; Also it is awesome to have the absolute minimum latency value, thanks.&lt;/p&gt;
&lt;p&gt;I do need to change the content of the buffer in every transfer of course. I will try to implement this solution throught the week and get back with a question or mark the problem as solved.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/thread/228412?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 16:35:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e99af384-61ca-47f7-8c8b-a7d573be5db0</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I did a quick test with the SPI driver in advanced mode. I setup a repeated transfer and connected the SPI END event to the START task, which means that the next transfer will start as soon as the previous is completed. As you can see from the image, I get a delay of 1.372 us between each 4 byte transfer. This is the lowest delay you can get, as everything happens in HW.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have also attached the main.c for your reference:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-1054c81cd9cf4b5c9b4c1fbe2bf972de/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&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><item><title>RE: Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/thread/228104?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 10:54:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21bbbfd6-4e5f-4472-8701-ae6cb08106d7</guid><dc:creator>Fran89</dc:creator><description>&lt;p&gt;Thank you very much for the prompt answer. I will test it out as soon as possible and let you know the results.&lt;/p&gt;
&lt;p&gt;For now I add a picture for future reference and clarification of what my problem is:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="246" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/51568.Capture.PNG" width="579" /&gt;&lt;/p&gt;
&lt;p&gt;The code is the one for the SPI example, with the delays removed. This doesn&amp;#39;t use SoftDevice or any other interrupts, and yet there is a delay of around 30 us. The idea would be to minimize this delay.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define SPI_INSTANCE  0 /**&amp;lt; SPI instance index. */
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);  /**&amp;lt; SPI instance. */
static volatile bool spi_xfer_done;  /**&amp;lt; Flag used to indicate that SPI instance completed the transfer. */

#define TEST_STRING &amp;quot;Nordic&amp;quot;
static uint8_t       m_tx_buf[] = TEST_STRING;           /**&amp;lt; TX buffer. */
static uint8_t       m_rx_buf[sizeof(TEST_STRING) + 1];    /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&amp;lt; Transfer length. */

/**
 * @brief SPI user event handler.
 * @param event
 */
void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
    spi_xfer_done = true;
    NRF_LOG_INFO(&amp;quot;Transfer completed.&amp;quot;);
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}

int main(void)
{
    //bsp_board_init(BSP_INIT_LEDS);

    //APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    //NRF_LOG_DEFAULT_BACKENDS_INIT();

    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SPI_SS_PIN;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));

    NRF_LOG_INFO(&amp;quot;SPI example started.&amp;quot;);

    while (1)
    {
        // Reset rx buffer and transfer done flag
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;

        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));

        while (!spi_xfer_done)
        {
            __WFE();
        }

        //NRF_LOG_FLUSH();

        //bsp_board_led_invert(BSP_BOARD_LED_0);
        //nrf_delay_ms(200);
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks again, and I will report back asap.&lt;/p&gt;
&lt;p&gt;Fran89&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reduce time between SPI transfers</title><link>https://devzone.nordicsemi.com/thread/227755?ContentTypeID=1</link><pubDate>Mon, 06 Jan 2020 16:13:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cab38b73-4ea9-4b92-bd79-6375604e0cff</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think we will need some more details in order to answer your questions. How have you configured the SPI driver? (non-blocking/blocking mode, SS signal being used, etc).&lt;/p&gt;
&lt;p&gt;Do you need to update the data that is being transferred every time you call the nrf_drv_spi_transfer? If this is static, you can use the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/hardware_driver_spi_master.html?cp=7_1_2_0_13_2#hardware_driver_spi_advanced"&gt;&amp;quot;advanced usage&amp;quot; features of the driver&lt;/a&gt; to setup a transfer and start it through PPI directly from a TIMER. This will minimize the time between transfers.&lt;/p&gt;
&lt;p&gt;If you need to change the content of the buffer, and are running BLE activity simultaneously, there is no way to guarantee the completion of the transfer in this short time, since the softdevice will always have the highest priority and will preempt the SPI transfer.&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>