<?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>Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60054/twi-transfers-never-complete</link><description>I am attempting to use SDK15 with the nrf52832 to communicate with multiple sensors over I2C. However, in the twi_sensor and twi_master_using_nrf_twi_mngr examples, as well as my own code adapted from these examples, the first twi transfer is never completed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 17 Apr 2020 15:55:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60054/twi-transfers-never-complete" /><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/245302?ContentTypeID=1</link><pubDate>Fri, 17 Apr 2020 15:55:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e4baf7f-942d-49b2-a6ee-c55aea365d5a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You are not using the external LF crystal (which is using P0.01) on your board? Is the firmware running as expected apart from the TWI pins not toggling? If not, you should debug the application to see where it stops.&lt;/p&gt;
&lt;p&gt;Can you post the full project for us to review and debug it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/244541?ContentTypeID=1</link><pubDate>Tue, 14 Apr 2020 18:04:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfd94d42-00a0-40a0-a520-58a5dbba4af3</guid><dc:creator>rbrooksher</dc:creator><description>&lt;p&gt;Pins 0.01 and 0.02 are SCL lines and pins 0.03 and 0.04 are SDA.&amp;nbsp;Rather than have two I2C busses with all four signal lines close together, would one I2C bus using non-adjacent traces reduce parasitic capacitance?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/244373?ContentTypeID=1</link><pubDate>Tue, 14 Apr 2020 09:34:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f3cc2f3-7232-4e11-aed2-ea85af3676f3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Which pins are you using for the TWI interfaces? I could not find the definition of&amp;nbsp;SCLx/SDAx in the code you posted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/244298?ContentTypeID=1</link><pubDate>Mon, 13 Apr 2020 18:15:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74a1d967-ca35-4ee0-aca3-c23585b99100</guid><dc:creator>rbrooksher</dc:creator><description>&lt;p&gt;I went in and looked at the signals, you&amp;#39;re right both SCL and SDA are pulled low. The SCL and SDA lines are configured to use the internal pullups of&amp;nbsp;the nrf52832, and the i2c sensors are mpu9250 breakout boards with 10kohm pullup resistors included. I had expected these to be sufficient, would stronger pullups with lower resistances solve the problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/244241?ContentTypeID=1</link><pubDate>Sat, 11 Apr 2020 08:06:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf00fc33-863f-45de-9525-0ddcab091465</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Use an oscilloscope to look at the I&amp;sup2;C signals.&lt;/p&gt;
&lt;p&gt;My guess is: You forgot the pullup resistors on you custom board, and SCL is pulled permanently LOW by parasitics.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/244230?ContentTypeID=1</link><pubDate>Fri, 10 Apr 2020 18:51:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2c8632e-c1e6-4069-9af8-9212a4fd7fb7</guid><dc:creator>rbrooksher</dc:creator><description>&lt;p&gt;I switched over from the twi_mngr implementation to nrfx_twi in my custom program and added address and data NACK handling. It runs successfully on the devkit, yet after the first tx call on the custom board&amp;nbsp;the twi event handler is never reached, with a NACK or otherwise. This leads me to believe the issue&amp;nbsp;is either a difference in between my&amp;nbsp;circuit board and the devkit or a difference between the nrf52832 and nrf52dk platforms. I have included the twi related code below in case it will shed some&amp;nbsp;light on the subject.&lt;/p&gt;
&lt;p&gt;twi_evt_handler&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void twi_evt_handler(nrfx_twi_evt_t const * p_event, void * p_context)
{
    switch (p_event-&amp;gt;type)
    {
        case NRFX_TWI_EVT_DONE:
          //if (p_event-&amp;gt;xfer_desc.type == NRF_DRV_TWI_XFER_RX)
          //{
            //data_handler(m_sample);
          //}
          m_xfer_done = true;
          break;
        case NRFX_TWI_EVT_ADDRESS_NACK:
          NRF_LOG_WARNING(&amp;quot;mpu9250 address nack&amp;quot;);
          twi_nack = true;
        case NRFX_TWI_EVT_DATA_NACK:
          NRF_LOG_WARNING(&amp;quot;mpu9250 data nack&amp;quot;);
          twi_nack = true;
        default:
          NRF_LOG_WARNING(&amp;quot;twi_evt_handler unknown evt&amp;quot;);
          break;
    }
}&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;twi_init&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void twi_init(void)
{
    ret_code_t err_code = 0;
    nrfx_twi_config_t twi0_mpu9250_config;
    twi0_mpu9250_config.scl                = SCL0;
    twi0_mpu9250_config.sda                = SDA0;
    twi0_mpu9250_config.frequency          = NRF_TWI_FREQ_100K;
    twi0_mpu9250_config.interrupt_priority = APP_IRQ_PRIORITY_LOW;
    //twi0_mpu9250_config.clear_bus_init     = false;
    twi0_mpu9250_config.hold_bus_uninit    = false;
    //err_code = nrf_twi_mngr_init(&amp;amp;m_nrf_twi_mngr0, &amp;amp;twi0_mpu9250_config);
    err_code = nrfx_twi_init(&amp;amp;m_twi0, &amp;amp;twi0_mpu9250_config, twi_evt_handler, NULL);
    APP_ERROR_CHECK(err_code);
    nrfx_twi_enable(&amp;amp;m_twi0);
    
    nrfx_twi_config_t twi1_mpu9250_config;
    twi1_mpu9250_config.scl                = SCL1;
    twi1_mpu9250_config.sda                = SDA1;
    twi1_mpu9250_config.frequency          = NRF_TWI_FREQ_100K;
    twi1_mpu9250_config.interrupt_priority = APP_IRQ_PRIORITY_LOW;
    //twi0_mpu9250_config.clear_bus_init     = false;
    twi1_mpu9250_config.hold_bus_uninit    = false;
    //err_code = nrf_twi_mngr_init(&amp;amp;m_nrf_twi_mngr1, &amp;amp;twi1_mpu9250_config);
    err_code = nrfx_twi_init(&amp;amp;m_twi1, &amp;amp;twi1_mpu9250_config, twi_evt_handler, NULL);
    APP_ERROR_CHECK(err_code);
    nrfx_twi_enable(&amp;amp;m_twi1);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;write_mpu9250&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void write_mpu9250(uint8_t * reg_addr, uint8_t * p_buffer, uint8_t byte_cnt)
{
  ret_code_t err_code = NRF_SUCCESS;
  uint8_t reg[byte_cnt + 1];
  reg[0] = *reg_addr;
  for(int i = 0; i &amp;lt; byte_cnt; i++){
    reg[i+1] = p_buffer[i];
  }
  m_xfer_done = false;
  twi_nack = false;
  if(current_mpu9250_id == 0){
    APP_ERROR_CHECK(nrfx_twi_tx(&amp;amp;m_twi0, MPU9250_ADDRESS, reg, 1, false));
    while(!m_xfer_done){
      if(twi_nack){
        twi_nack = false;
        APP_ERROR_CHECK(nrfx_twi_tx(&amp;amp;m_twi0, MPU9250_ADDRESS, reg, 1, false));
      }
    }
  }
  if(current_mpu9250_id == 1){
    APP_ERROR_CHECK(nrfx_twi_tx(&amp;amp;m_twi1, MPU9250_ADDRESS, reg, 1, false));
    while(!m_xfer_done){
      if(twi_nack){
        twi_nack = false;
        APP_ERROR_CHECK(nrfx_twi_tx(&amp;amp;m_twi1, MPU9250_ADDRESS, reg, 1, false));
      }
    }
  }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/244198?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 21:39:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8179c2ef-c8f6-467c-86f6-f58caebdde20</guid><dc:creator>rbrooksher</dc:creator><description>&lt;p&gt;I was able to nail down the cause of the error 0x03 with the devkit as a NACK in the twi manager&amp;#39;s built in event handler. However, the custom board still hangs with no calls to callbacks or event handlers. The custom board has a direct connection to the I2C sensors, just like the devkit. Is there something internal with the nrf52832 that could be interfering with twi, or could the pin traces be too close together and interfering with each other? The traces are a minimum of .4mm apart at all points.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Twi Transfers Never Complete</title><link>https://devzone.nordicsemi.com/thread/244189?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 19:56:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b8492cc-7ba3-44a8-bece-41783664a225</guid><dc:creator>rbrooksher</dc:creator><description>&lt;p&gt;Update: Attempting to run the same example on the nrf52 DK provided some more info. The twi_scanner successfully identified the device address as 0x68. However, the twi_mngr example returns error&amp;nbsp;0x03 for cb_data.transaction_result during&amp;nbsp;nrf_twi_mngr_perform calls. The development kit still hangs on the twi_sensor example at line 96 in main.c, &amp;quot;while (m_xfer_done == false);&amp;quot;. This leads me to believe the problem is related to the interrupt/callback handling, but because the examples also exhibit this behavior I am unsure where to go from here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void LM75B_set_mode(void)
{
    ret_code_t err_code;

    /* Writing to LM75B_REG_CONF &amp;quot;0&amp;quot; set temperature sensor in NORMAL mode. */
    uint8_t reg[2] = {LM75B_REG_CONF, NORMAL_MODE};
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, LM75B_ADDR, reg, sizeof(reg), false);
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false);

    /* Writing to pointer byte. */
    reg[0] = LM75B_REG_TEMP;
    m_xfer_done = false;
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, LM75B_ADDR, reg, 1, false);
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>