<?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>nRF51822 TWI + s110</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11919/nrf51822-twi-s110</link><description>I tried all the examples TWI code on my device and a dev kit nRF51-DK. Nothing appeared to work, either I get a into the WDT handler or the nRF51 resets. 
 While combing through the forums I stumbled upon a file posted dated 2009 called sd_twi_master</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Feb 2016 13:31:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11919/nrf51822-twi-s110" /><item><title>RE: nRF51822 TWI + s110</title><link>https://devzone.nordicsemi.com/thread/45150?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2016 13:31:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbc08691-65af-4218-97f9-96e99cc85fc2</guid><dc:creator>ypearson</dc:creator><description>&lt;p&gt;My solution was posted here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/68074/twi-demo-code-on-nrf51-dk-resets/"&gt;my twi solution&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51822 TWI + s110</title><link>https://devzone.nordicsemi.com/thread/45149?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2016 08:59:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dbb82f6-e525-466a-be79-01b6e8f1a78a</guid><dc:creator>Fredrik Sundt Brynhildsvoll</dc:creator><description>&lt;p&gt;Hello,
I would recommend to use the TWI master hardware driver. Some documentation can be found &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/hardware_drivers.html"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This driver run in two different modes: blocking mode and non-blocking mode. If an interrupt handler is not provided when initializing the twi event then the mode will be blocking mode. It will not return until the task is completed.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = nrf_drv_twi_init(&amp;amp;twi, NULL, NULL); //No interrupt handler provided
err_code =  nrf_drv_twi_tx(&amp;amp;twi, SLAVE_ADDRESS, tx_Data. sizeof(tzx_data), false); //Will  always return NRF_SUCCESS, BEFORE the transmission is completed!
err_code = nrf_drv_twi_rx(&amp;amp;twi, SLAVE_ADDRESS, tx_data, sizeof(tx_data), false); //Will always return NRF_SUCCESS, BEFORE the transmission is completed!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is also possible to provide an interrupt handler to the twi driver. Then the events can handled there. The event handler below is taken from another post here on &lt;a href="https://devzone.nordicsemi.com/question/48894/hardware-twii2c-example/"&gt;devzone&lt;/a&gt;. It is very handy if one want to test the I2C connection, because it lights up if an I2C device is found.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; TWI event handler. Processing TWI events originating from nrf_drv_twi_tx()
static void twi_event_handler(nrf_drv_twi_evt_t *evt){     
    // Light up LED 1 if device found
    if(evt-&amp;gt;type == NRF_DRV_TWI_TX_DONE)
    {
        nrf_gpio_pin_clear(LED_1);
    }
}

err_code = nrf_drv_twi_init(&amp;amp;twi, NULL, twi_event_handler); //Setting up the event handler
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am currently writing a blog post about how twi can be implemented on nRF5x chips, but it is not ready yet. I will update this post when I am done. In the meantime you can have a look at a previous post where TWI is &lt;a href="https://devzone.nordicsemi.com/question/65368/i2c-interface-with-htu21d-using-nrf51822/"&gt;implemented&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;EDIT: For anyone interested I have now made a blog post which describe how twi can be implemented on the nrf52 chip. It can be found &lt;a href="https://devzone.nordicsemi.com/blogs/860/readiing-humidity-from-htu21d-sensor-using-twi/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>