<?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>Help with using TWI with the NRF52832 (SES studio)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28145/help-with-using-twi-with-the-nrf52832-ses-studio</link><description>Hi everyone, 
 So I&amp;#39;ve this arduino code that utilizes the I2C library and made some convertions to it to work with the nrf52832 in the segger embedded studio and when debugging the code never passes the
&amp;quot;err_code = nrf_drv_twi_tx();&amp;quot; 
 function and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 12 Dec 2017 14:14:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28145/help-with-using-twi-with-the-nrf52832-ses-studio" /><item><title>RE: Help with using TWI with the NRF52832 (SES studio)</title><link>https://devzone.nordicsemi.com/thread/111121?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 14:14:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e511c77-5b5f-48b9-8db3-dcde0ed231b5</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;to this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;switch (p_event-&amp;gt;type)
{
    case NRF_DRV_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 NRF_DRV_TWI_EVT_ADDRESS_NACK:
		/**************************************
		 * Handle this case and/or check if your code hits this point with a debugger
		 **************************************/
        break;
    case NRF_DRV_TWI_EVT_DATA_NACK:
		/**************************************
		 * Handle this case and/or check if your code hits this point with a debugger
		 **************************************/
        break;
    default:
        break;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Help with using TWI with the NRF52832 (SES studio)</title><link>https://devzone.nordicsemi.com/thread/111120?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 14:13:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ac9652a-5cb1-483d-8a3b-a033fb6a9141</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Expand the content of your TWI event handler from this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;switch (p_event-&amp;gt;type)
{
    case NRF_DRV_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;
    default:
        break;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Help with using TWI with the NRF52832 (SES studio)</title><link>https://devzone.nordicsemi.com/thread/111119?ContentTypeID=1</link><pubDate>Sat, 09 Dec 2017 22:05:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a1ecf31-6aaf-42a9-8d5d-42264fb8b84e</guid><dc:creator>MikeLemon</dc:creator><description>&lt;p&gt;Hi sorry for the late replay what do you mean by implementing those cases in the event handler?
How should I modify the code for that?&lt;/p&gt;
&lt;p&gt;And yeah the wiring are correct as I&amp;#39;ve ran the I2C device scanner example and it manager to read the correct address|!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Help with using TWI with the NRF52832 (SES studio)</title><link>https://devzone.nordicsemi.com/thread/111118?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2017 14:00:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fa4f857-8cad-4cac-b188-483b95809938</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You should implement the other two possible cases in your event handler too:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_DRV_TWI_EVT_DONE,         ///&amp;lt; Transfer completed event.
NRF_DRV_TWI_EVT_ADDRESS_NACK, ///&amp;lt; Error event: NACK received after sending the address.
NRF_DRV_TWI_EVT_DATA_NACK     ///&amp;lt; Error event: NACK received after sending a data byte.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If your TWI bus of some reason is misbehaving you won&amp;#39;t get a NRF_DRV_TWI_EVT_DONE event, and hence &lt;code&gt;m_xfer_done&lt;/code&gt; will never be set to true and you will be stuck in the while loop. If you implement the other cases you can also debug and check whether your sensor responds at all. Make sure to check and double check your wiring.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>