<?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>nrf51822 SPI timing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50129/nrf51822-spi-timing</link><description>Hi, 
 I working on a project that need to communicate with other mcu by SPI, the communication is work, but I have question about the start and stop of communication. 
 
 The version now using is: nrf51822, s130, SDK12. 
 SPI setting: master, 125KHz </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 Jul 2019 07:50:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50129/nrf51822-spi-timing" /><item><title>RE: nrf51822 SPI timing</title><link>https://devzone.nordicsemi.com/thread/200412?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2019 07:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8449b862-4cb0-4d14-af53-fd68f08d4a40</guid><dc:creator>FUNG</dc:creator><description>&lt;p&gt;Hi niebert,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for your reply.&lt;/p&gt;
&lt;p&gt;And the code is from spi example in SDK12.2:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
int main(void)
{
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));

    NRF_LOG_INFO(&amp;quot;SPI example\r\n&amp;quot;);

	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;
		
	spi_config.frequency = NRF_DRV_SPI_FREQ_125K;
	spi_config.mode = NRF_DRV_SPI_MODE_3;
	spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_LSB_FIRST;
		
//    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler));
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, NULL));

	m_tx_buf[0] = 0x5A;
	m_tx_buf[1] = 0x16;
	m_tx_buf[2] = 0x01;
	m_tx_buf[3] = 0x80;
	m_tx_buf[4] = 0x00;

    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, 5, m_rx_buf, 5));

//        while (!spi_xfer_done)
//        {
//            __WFE();
//        }

        nrf_delay_ms(1000);
    }

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;without the softdevice, the delay is little bit shorter.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Logic_5F00_view21_2800_withoutS130_2900_.png" /&gt;&lt;/p&gt;
&lt;p&gt;I trace the code&amp;nbsp;nrf_drv_spi.c and&amp;nbsp;can&amp;#39;t know where the time is come from.&lt;/p&gt;
&lt;p&gt;Thanks.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 SPI timing</title><link>https://devzone.nordicsemi.com/thread/199948?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 08:24:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ac46b48-e8f9-45fa-b746-d18e1834b15c</guid><dc:creator>niebert</dc:creator><description>&lt;p&gt;(a) I see no good reason to develop for Nrf51822 today. Nrf52810 is cheaper and MUCH&amp;nbsp;more powerful. Check it out.&lt;/p&gt;
&lt;p&gt;(b) That said, the delays you observe are in the low hundreds of CPU cycles and&amp;nbsp;can well be due to software latency in the library and in your code. I do not think they are deliberate in the SDK, but maybe in some other code you are using? Without a code snippet, impossible to tell. By optimisation or by writing your own integrated driver, you might be able to reduce this latency, but never get completely rid of it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>