<?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>Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51026/problems-porting-application-from-nrf52dk-board-to-custom-board</link><description>I am trying to port an application that works on the NRF52 DK board to a custom board containing a 52832 QFAA chipset. The MCU is connected via SPI to an IMU BMI160 and a SD card slot. In debug mode, the program downloaded successfully to the custom board</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Aug 2019 01:04:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51026/problems-porting-application-from-nrf52dk-board-to-custom-board" /><item><title>RE: Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/thread/205993?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 01:04:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd14c490-8768-4489-893f-f58b77820bce</guid><dc:creator>Ed Ang</dc:creator><description>&lt;p&gt;Thank you, Simon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/thread/204412?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2019 08:09:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc749da4-5f29-4a03-b638-c0738e3bff27</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Ed&lt;/p&gt;
&lt;p&gt;The SPI may &amp;quot;hang&amp;quot; when stepping through it, as it has a few time-sensitive functions, that depend on the events from the other side not being missed and so on. So what likely is happening, is that your function is stuck in some while loop within&amp;nbsp;one of your functions waiting for an SPI/SPIM event that it missed because stepping through the code is &amp;quot;too slow&amp;quot;. Where exactly it is stuck however is hard to say based on what information I have. One example is that it&amp;#39;s stuck in nrfx_spim.c where the&lt;strong&gt;&amp;nbsp;if (!p_cb-&amp;gt;handler)&amp;nbsp;&lt;/strong&gt;calls a check for NRF_SPIM_EVENT_END, which could have been missed when stepping through the code.&lt;/p&gt;
&lt;p&gt;What you&amp;#39;ll have to do, is to see what&amp;#39;s going on in the nrf_drv_spi_transfer() function, and see where exactly it hangs within that function.&lt;/p&gt;
&lt;p&gt;Best of luck and regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/thread/204336?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 13:57:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65c75de6-299b-4f91-bcbf-b04790f272e1</guid><dc:creator>Ed Ang</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Yes, the place where it hangs is in line 23 - the program downstream of line 23 do not execute. The other lines are positioned down the stack trace.&lt;/p&gt;
&lt;p&gt;The problem is consistent and reproducible.&lt;/p&gt;
&lt;p&gt;Yes, the program works on the DK.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ed&lt;/p&gt;
&lt;p&gt;&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: Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/thread/204318?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 13:19:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb97458d-da24-4d5e-b2cf-957b6dd1fcd7</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Ed&lt;/p&gt;
&lt;p&gt;Sorry, but do you mean that your application fails on all these lines? Does this happen at random or what do you mean that they fail at the following lines? This initialization works fine on a DK, correct?&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><item><title>RE: Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/thread/204294?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 12:03:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f803f9b8-8cb5-4d42-90e4-d0ab45ef7e68</guid><dc:creator>Ed Ang</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int8_t bmi160_init(struct bmi160_dev *dev)
{
    int8_t rslt;
    uint8_t data;
    uint8_t try = 3;

    /* Null-pointer check */
    rslt = null_ptr_check(dev);

    /* Dummy read of 0x7F register to enable SPI Interface
     * if SPI is used */
    if ((rslt == BMI160_OK) &amp;amp;&amp;amp; (dev-&amp;gt;interface == BMI160_SPI_INTF))
    {
        rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &amp;amp;data, 1, dev);
    }
    if (rslt == BMI160_OK)
    {
        /* Assign chip id as zero */
        dev-&amp;gt;chip_id = 0;
        while ((try--) &amp;amp;&amp;amp; (dev-&amp;gt;chip_id != BMI160_CHIP_ID))
        {
            /* Read chip_id */
            rslt = bmi160_get_regs(BMI160_CHIP_ID_ADDR, &amp;amp;dev-&amp;gt;chip_id, 1, dev);
        }
        if ((rslt == BMI160_OK) &amp;amp;&amp;amp; (dev-&amp;gt;chip_id == BMI160_CHIP_ID))
        {
            dev-&amp;gt;any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED;

            /* Soft reset */
            rslt = bmi160_soft_reset(dev);
        }
        else
        {
            rslt = BMI160_E_DEV_NOT_FOUND;
        }
    }

    return rslt;
}

int8_t bmi160_get_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev)
{
    int8_t rslt = BMI160_OK;

    /* Null-pointer check */
    if ((dev == NULL) || (dev-&amp;gt;read == NULL))
    {
        rslt = BMI160_E_NULL_PTR;
    }
    else
    {
        /* Configuring reg_addr for SPI Interface */
        if (dev-&amp;gt;interface == BMI160_SPI_INTF)
        {
            reg_addr = (reg_addr | BMI160_SPI_RD_MASK);
        }
        
        rslt = dev-&amp;gt;read(dev-&amp;gt;id, reg_addr, data, len);
        
        if (rslt != BMI160_OK)
        {
            rslt = BMI160_E_COM_FAIL;
        }
    }

    return rslt;
}

int8_t nrf_acc_read_register(uint8_t dev_id, uint8_t reg_addr, uint8_t* payload, uint16_t payload_size) {
  uint8_t m_buf[payload_size+1];
  m_buf[0] = reg_addr;
  uint8_t read_temp[ payload_size + 1 ] ;
  
  read_reg = true;
  spi_xfer_done = false;
  
  //int8_t ret = nrf_drv_spi_transfer(&amp;amp;spi_BMI160, m_buf, 1, m_rx_buf, payload_size+1);
  int8_t ret = nrf_drv_spi_transfer(&amp;amp;spi_BMI160, m_buf, 1, read_temp, payload_size+1);
  APP_ERROR_CHECK(ret);
  nrf_delay_ms(5);
  
  for( int i = 1 ; i &amp;lt; payload_size+1 ; i ++ )
    payload[i-1] = read_temp[i] ;
  
  return ret;	
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The application is failing during the initialisation phase, at the following lines (down the call stack).&lt;/p&gt;
&lt;p&gt;l23:&amp;nbsp;rslt = bmi160_get_regs(BMI160_CHIP_ID_ADDR, &amp;amp;dev-&amp;gt;chip_id, 1, dev);&lt;/p&gt;
&lt;p&gt;l58:&amp;nbsp;rslt = dev-&amp;gt;read(dev-&amp;gt;id, reg_addr, data, len);&lt;/p&gt;
&lt;p&gt;l78:&amp;nbsp;int8_t ret = nrf_drv_spi_transfer(&amp;amp;spi_BMI160, m_buf, 1, read_temp, payload_size+1);&lt;br /&gt; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any help appreciated, thanks.&lt;/p&gt;
&lt;p&gt;Ed&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/thread/204279?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 11:14:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47cc29f5-85f2-4a2e-89af-4c99ce00f308</guid><dc:creator>Ed Ang</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thanks for getting back so quickly. No error is returned - it simply freezes and block the whole application.&lt;/p&gt;
&lt;p&gt;No, it isn&amp;#39;t one of the examples. It is a custom application we wrote in order to test the IMU and the SD card slot.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I just tried loading the example &amp;#39;spi_pca10040&amp;#39;, and I got the log messages &amp;#39;&amp;quot;Transfer completed.&amp;quot;&amp;#39;, and no exceptions are returned.&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Ed&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems porting application from NRF52DK board to custom board</title><link>https://devzone.nordicsemi.com/thread/204273?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 11:03:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bc3a3b4-4787-453f-8181-e47cd5bfba2c</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Ed&lt;/p&gt;
&lt;p&gt;Are you able to see what error the nrf_drv_spi_transfer() returns? Is your project based on one of our SDK examples? If so, what example, and what changes have been made to it?&lt;/p&gt;
&lt;p&gt;Are you able to flash and run any example to the chip to see that it works properly?&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>