<?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 Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52383/spi-communication-problems-concerning-nrf52840</link><description>Now there is a project, nrf52840 uses SPI to communicate with other microcontrollers. Data is currently available, but it is suspected that each packet lacks a second byte. The corresponding modification of SPI mode eliminates the problem of SPI mode</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Oct 2019 14:01:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52383/spi-communication-problems-concerning-nrf52840" /><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/213959?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 14:01:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f13aae4c-1bd4-4ac8-8ee5-462cf522f8b1</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I assume that this is the same issue/question as in your other ticket?&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/52719/spis-of-nrf52-could-not-read-the-data-accuracy"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/52719/spis-of-nrf52-could-not-read-the-data-accuracy&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/213857?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 10:39:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d453b07c-f296-4ffe-b847-380378579877</guid><dc:creator>hzhuxin</dc:creator><description>&lt;p&gt;Any solution avaliable?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211116?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 07:37:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8efe1414-d143-4119-b2ba-182425a0d8b6</guid><dc:creator>hzhuxin</dc:creator><description>&lt;p&gt;I am the colleague of June6,&amp;nbsp; give more information for the problem.&lt;/p&gt;
&lt;p&gt;We are using the SPIS sample in&amp;nbsp;examples\peripheral\spis of15.3 SDK.&lt;br /&gt;As show in the above Oscilloscope, the second bytes had sent after a long time after the first bytes(maybe 4.34 ms), and i read the rx_amount of&amp;nbsp;&lt;span&gt;nrf_drv_spis_event_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;event in callback&amp;nbsp;spis_event_handler, the value always is 1.&lt;br /&gt;In this period, there are two bytes clk cycles(that mean clk has the&amp;nbsp; 16 high low in turn) &amp;amp; two bytes appear there, and at the same time, the cs is low, so according the spi protocol, i should received two bytes, am i right?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;After this period, the cs cycle changed to 500us, and in one cycle, there is a clk cycle(8 high low in turn), the interval is very short(maybe 30us), these data received perfect.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please give us some suggestion on how to get the second bytes? how to modify the program?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211102?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 06:44:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f97cb9f2-566c-47e2-acdc-d5bbc58acf77</guid><dc:creator>June6</dc:creator><description>&lt;p&gt;The above engineering path is corrected to sdk15.3 examples\peripheral\spis&lt;span&gt;\pca10040&amp;nbsp; &amp;nbsp; &amp;nbsp; (52832)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211061?ContentTypeID=1</link><pubDate>Sun, 22 Sep 2019 07:49:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e752f968-a556-4d95-8179-e1b1b247cfaa</guid><dc:creator>June6</dc:creator><description>&lt;p&gt;&lt;span&gt;The normal chip selection cycle is 500us. However, the first chip selection cycle&amp;nbsp;is 4.34ms.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211056?ContentTypeID=1</link><pubDate>Sun, 22 Sep 2019 07:22:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52e2de2d-a99d-42c1-aed2-b6ad399a9c97</guid><dc:creator>June6</dc:creator><description>&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/_AE5FE14FFE5647725F00_201909211.jpg" /&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;The above is the waveform of data pin and chip selection pin.（The yellow waveform is the data pin waveform. The blue waveform is the chip selection pin waveform. And chip selection is pin low level effective）&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="src"&gt;Through the analysis of chip selection waveform and data, it is found that chip selection pin is always valid after the data transmission of the first byte, and invalid only after the data transmission of the second byte.&lt;/span&gt;&lt;span class="src"&gt;Therefore, the data of the second byte is lost due to this problem.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211043?ContentTypeID=1</link><pubDate>Sat, 21 Sep 2019 16:34:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1bb5979-4b4a-41f6-986d-fa3842d120a7</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Try this driver instead. &amp;nbsp;it is much better and easier to use. &amp;nbsp;it has been used&amp;nbsp;in many projects and&amp;nbsp;hundreds of devices, sensors, flash memory, sd card...&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/spi_nrf5x.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/spi_nrf5x.cpp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;usage example&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/exemples/spi/spi_master_slave.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/exemples/spi/spi_master_slave.cpp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211042?ContentTypeID=1</link><pubDate>Sat, 21 Sep 2019 14:40:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2428c20f-93a3-4e05-bc95-60239266e0d3</guid><dc:creator>June6</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define TEST_STRING &amp;quot;Nordic 1234567890123&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. */

static volatile bool spis_xfer_done; /**&amp;lt; Flag used to indicate that SPIS instance completed the transfer. */

void spis_event_handler(nrf_drv_spis_event_t event)
{
    static uint8_t MyString[DATA_BUFFER_SIZE];
    static uint8_t MyStringIndex = 0;
    int i, j;
    uint8_t *StartPointer, *NextPointer;
    if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
    {
        spis_xfer_done = true;
        if (MyStringIndex == DATA_BUFFER_SIZE)
         {
//            NRF_LOG_INFO(&amp;quot; Transfer completed. Received: %d\n&amp;quot;, MyStringIndex);

            //Find the first Data
            for (i = 0; i &amp;lt; DATA_BUFFER_SIZE; i ++)
              if (MyString[i] == 0x80 || MyString[i] == 0x90 || MyString[i] == 0xa0)
              break;

            if (i &amp;lt; DATA_BUFFER_SIZE)
            {
              StartPointer = &amp;amp;MyString[i]; 

            while ((StartPointer != NULL) &amp;amp;&amp;amp; (StartPointer &amp;lt; (&amp;amp;MyString[DATA_BUFFER_SIZE - 1])) &amp;amp;&amp;amp; (StartPointer + 16 &amp;lt; (&amp;amp;MyString[DATA_BUFFER_SIZE - 1])) )
            {
              NextPointer = StartPointer + 1;
              //Find the ending of the data
              for (j = 1; j &amp;lt; 16; j ++, NextPointer ++)
              {
                if (*NextPointer == 0x80 || *NextPointer == 0x90 || *NextPointer == 0xa0)
                break;
              }

              //Show the data to RTT or UART
              NRF_LOG_HEXDUMP_INFO(StartPointer, j);
              StartPointer += j;
            }

            memset(MyString, 0, 100);
            MyStringIndex = 0;
          }
         }
         MyString[MyStringIndex] = m_rx_buf[0];
         MyStringIndex ++;
  }
}

int main(void)
{
    // Enable the constant latency sub power mode to minimize the time it takes
    // for the SPIS peripheral to become active after the CSN line is asserted
    // (when the CPU is in sleep mode).
    NRF_POWER-&amp;gt;TASKS_CONSTLAT = 1;

    bsp_board_init(BSP_INIT_LEDS);
 
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO(&amp;quot;SPIS example&amp;quot;);

    nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;
    spis_config.mode = NRF_SPIS_MODE_1;
    spis_config.csn_pin               = APP_SPIS_CS_PIN;
    spis_config.miso_pin              = APP_SPIS_MISO_PIN;
    spis_config.mosi_pin              = APP_SPIS_MOSI_PIN;
    spis_config.sck_pin               = APP_SPIS_SCK_PIN;


    APP_ERROR_CHECK(nrf_drv_spis_init(&amp;amp;spis, &amp;amp;spis_config, spis_event_handler));

    while (1)
    {
        spis_xfer_done = false;

        APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&amp;amp;spis, m_tx_buf, 0, m_rx_buf, 20));

        while (!spis_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();

//        bsp_board_led_invert(BSP_BOARD_LED_0);
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211038?ContentTypeID=1</link><pubDate>Sat, 21 Sep 2019 08:26:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:280f18ec-19c1-4157-afea-674acd49ad71</guid><dc:creator>June6</dc:creator><description>&lt;p&gt;Can you test whether you will lose data when receiving data with SPI?&amp;nbsp;The data received by SPI in my program is only 16 bytes, but the data transferred is actually 17 bytes. I lost the second byte data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211037?ContentTypeID=1</link><pubDate>Sat, 21 Sep 2019 08:21:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ac6b77c-bec9-41b6-bbf2-4de5dc45f158</guid><dc:creator>June6</dc:creator><description>&lt;p&gt;HI Edvin,Now it turns out that the second byte data is missing when receiving data.&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/_AE5FE14FFE5647725F00_20190921161939.jpg" /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/_AE5FE14FFE5647725F00_20190921161942.jpg" /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/_AE5FE14FFE5647725F00_20190921161945.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/211015?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2019 17:09:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc3352b5-24c7-4c2d-b6dd-1f3b1ae0c2c3</guid><dc:creator>June6</dc:creator><description>&lt;p&gt;All right. That&amp;#39;s what I&amp;#39;m going to do. The day after tomorrow, I will connect the data source directly to the oscilloscope to monitor the data waveform, so that I can know where the problem is.&amp;nbsp;Thank you for your reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/210963?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2019 13:37:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d20b5701-ce53-4a38-8442-f3eb57b16748</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Can you try to analyze the SPI MOSI and MISO lines to see if you are actually missing any data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication Problems Concerning nRF52840</title><link>https://devzone.nordicsemi.com/thread/210807?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2019 03:06:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d6e0596-bd32-4259-b90f-0d1213077784</guid><dc:creator>June6</dc:creator><description>&lt;div class="trans-left"&gt;
&lt;div class="trans-input-wrap"&gt;
&lt;div class="input-wrap" dir="ltr"&gt;
&lt;div class="textarea-wrap without-textarea-bg"&gt;
&lt;div class="textarea-bg-text" id="textarea-bg-text"&gt;Hope to be helped.&lt;/div&gt;
&lt;div class="textarea-bg-text"&gt;Best wishes&lt;/div&gt;
&lt;div class="textarea-bg-text"&gt;June6&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>