<?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>How to handle NACK in I2C (TWI) communication.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44525/how-to-handle-nack-in-i2c-twi-communication</link><description>Hi, 
 I am using nrf52832AA, SDK15.0, SD s131. 
 In some cases, an NRF_DRV_TWI_EVT_ADDRESS_NACK event occurs during I2C communication with the IQS263 sensor. 
 It would be nice if I could not get a NACK, but I do not know the exact cause yet. 
 How do</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 Mar 2019 08:56:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44525/how-to-handle-nack-in-i2c-twi-communication" /><item><title>RE: How to handle NACK in I2C (TWI) communication.</title><link>https://devzone.nordicsemi.com/thread/176895?ContentTypeID=1</link><pubDate>Tue, 19 Mar 2019 08:56:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3818015-d196-4c13-94d7-1f84c1d4aa93</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I think this is the right approach, and it seems like the reason for the NACK signal is due to the sensor being busy at the moment. However, I found a nice blog post &lt;a href="https://blog.digilentinc.com/i2c-how-does-it-work/"&gt;here&lt;/a&gt; that explains how to handle I2C NACK signals.&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: How to handle NACK in I2C (TWI) communication.</title><link>https://devzone.nordicsemi.com/thread/175798?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 01:31:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d811f9a7-ee51-4b44-a78b-df589cc5dabc</guid><dc:creator>powerup</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t found the exact cause of getting a&amp;nbsp;NACK yet.&lt;br /&gt;Thus, the code was modified as follows to enable it to function even when it received NACK.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void IQS263_reg_read(uint8_t reg, uint8_t* rx, uint8_t len){
    ret_code_t err_code;

    uint8_t myTX[1] = {reg};
    m_xfer_done = false;
    do{
      while(nrf_gpio_pin_read(RDY) == 1);
      err_code = nrf_drv_twi_tx(&amp;amp;CDC_twi_master, CDC_ADDRESS, myTX, 1, true);
      APP_ERROR_CHECK(err_code);
      nrf_delay_us(500);
    }while (m_xfer_done == false);
    //while (m_xfer_done == false);

    err_code = nrf_drv_twi_rx(&amp;amp;CDC_twi_master, CDC_ADDRESS, rx, len);
    APP_ERROR_CHECK(err_code);
    nrf_delay_ms(1);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;We used &amp;quot;do,while&amp;quot; instead of &amp;quot;while&amp;quot; to send the data again when we received &amp;quot;nack&amp;quot;.&lt;br /&gt;Is there any problem with this?&lt;br /&gt;Or is there another way?&lt;/p&gt;
&lt;p&gt;(It would be best not to receive the NACK, but we haven&amp;#39;t found the exact cause. T^T)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;PU&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to handle NACK in I2C (TWI) communication.</title><link>https://devzone.nordicsemi.com/thread/175350?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2019 13:52:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2601a8d8-0204-4e08-923e-25ddb6c3a509</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Receiving a NACK indicates that something is wrong, and according to &lt;a href="http://www.ti.com/lit/an/slva704/slva704.pdf"&gt;this&lt;/a&gt; document it&amp;nbsp;may be due one of the following conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&amp;quot;The receiver is unable to receive or transmit because it is performing some real-time function and is not ready to start communication with the master.&amp;quot;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&amp;quot;During the transfer, the receiver gets data or commands that it does not understand.&amp;quot;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&amp;quot;During the transfer, the receiver cannot receive any more data bytes.&amp;quot;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You should check with your sensor, if any of the following conditions may happen.&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>