<?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>I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/1843/i2c-example-with-nrf51822</link><description>Are there any I2C examples for the nRF51822 ( write/ read functions) ?
If not, can anyone suggest a good starting point for I2C?
I am using Eclipse kepler for development.
Thank you for all suggests.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Aug 2016 07:38:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/1843/i2c-example-with-nrf51822" /><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7980?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2016 07:38:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:356ebd2a-2935-4311-b348-67e76009f968</guid><dc:creator>ALi</dc:creator><description>&lt;p&gt;copy these files (.c,.h) to near Project main.c file and after that import to your project in Keil.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7986?ContentTypeID=1</link><pubDate>Tue, 03 May 2016 18:10:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1268a832-4596-4ccf-9259-94291e8f3f52</guid><dc:creator>Chris Lovett</dc:creator><description>&lt;p&gt;Ok, you are right, it looks like my code is using an older version of the Nordic sdk.  The new examples that are bundled with Keil C use nrf_drv_twi_init and nrf_drv_twi_tx.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7985?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2016 22:54:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92d966f9-6b38-458f-a750-d436b6d6ff37</guid><dc:creator>Chris Lovett</dc:creator><description>&lt;p&gt;My code is assuming the SoftDevice is available, so you must have called twi_master_init already, then my helper functions can work from there using twi_master_transfer.  A read is also a &amp;quot;transfer&amp;quot; because you have to write the register address that you want to read from.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7984?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2016 22:14:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d34621fd-4f14-4630-b75b-f690d70320c6</guid><dc:creator>Brook Gebremedhin</dc:creator><description>&lt;p&gt;@clovett ,&lt;/p&gt;
&lt;p&gt;i was seeing your wrapper you used  &lt;strong&gt;twi_master_transfer&lt;/strong&gt; both for reading and writing i2c data.&lt;/p&gt;
&lt;p&gt;dont we need to use  &lt;strong&gt;nrf_drv_twi_tx and nrf_drv_twi_rx&lt;/strong&gt;  as well ?&lt;/p&gt;
&lt;p&gt;And what will be the twi initialization in this case ?
tnx&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7983?ContentTypeID=1</link><pubDate>Sun, 19 Apr 2015 17:15:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbbc4ebf-b3c2-40a9-b36d-240b34db6268</guid><dc:creator>muhkuhns</dc:creator><description>&lt;p&gt;This won&amp;#39;t work with Softdevices enabled - will it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7979?ContentTypeID=1</link><pubDate>Wed, 04 Feb 2015 17:58:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1041869-9d57-4868-81c2-09540ab5866f</guid><dc:creator>Mario</dc:creator><description>&lt;p&gt;Hi Steve,
I saw that link. It appears under &amp;quot;drivers&amp;quot;. I do have the &amp;quot;twi_master.h&amp;quot;, &amp;quot;twi_hw_master.c&amp;quot; and &amp;quot;twi_sw_master.c&amp;quot; within drivers folder, but in examples folder I can&amp;#39;t find anything related with TWI or I2C. I don&amp;#39;t know what is wrong but I&amp;#39;m getting a headache with this.&lt;/p&gt;
&lt;p&gt;If I create a project and write #include &amp;quot;twi_master.h&amp;quot; it says it can&amp;#39;t find that file. It doesn&amp;#39;t happen with &amp;quot;simple_uart.h&amp;quot; for example and I don&amp;#39;t understand why because both of them are within the same folder &amp;quot;drivers&amp;quot; (where the uvision is supossed to find header files)&lt;/p&gt;
&lt;p&gt;The path of my examples folder is this&lt;/p&gt;
&lt;p&gt;C:\Keil_v5\ARM\Pack\NordicSemiconductor\nRF_Examples\7.2.0\peripheral&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7978?ContentTypeID=1</link><pubDate>Wed, 04 Feb 2015 16:43:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d063eb31-206a-4654-8dff-e3646539cb84</guid><dc:creator>Steven Wik</dc:creator><description>&lt;p&gt;Hi Mario,&lt;/p&gt;
&lt;p&gt;Have you tried this link &lt;a href="http://developer.nordicsemi.com/nRF51_SDK/doc/7.2.0/s110/html/a00008.html"&gt;here&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure why you can&amp;#39;t find the example in your SDK&amp;#39;s file path - it looks like the latest SDK still has the example under the nrf6310 folder.  Are you looking in the correct folder?&lt;/p&gt;
&lt;p&gt;-Steve&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7977?ContentTypeID=1</link><pubDate>Wed, 04 Feb 2015 16:34:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:177b25d5-e535-404c-9903-c1c9bd723f46</guid><dc:creator>Mario</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am trying to find the I2C example and I can&amp;#39;t. It doesn&amp;#39;t appear here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://developer.nordicsemi.com/nRF51_SDK/doc/7.2.0/s110/html/a00038.html"&gt;developer.nordicsemi.com/.../a00038.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And it doesn&amp;#39;t either in my PC folder. It is possible that it was available in SDK v5.1.0 version but it&amp;#39;s not anymore?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7988?ContentTypeID=1</link><pubDate>Thu, 24 Apr 2014 20:43:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3535798a-fbb8-4de5-9abb-a7ba89a6eb0f</guid><dc:creator>Chris Lovett</dc:creator><description>&lt;p&gt;Yeah, it looks like twi_sw_master.c is designed to work with only one channel. Notice how it hard codes your twi_master_config.h definitions of TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER and TWI_MASTER_CONFIG_DATA_PIN_NUMBER. So if you do something like this:&lt;/p&gt;
&lt;p&gt;#define TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER (23U)
#define TWI_MASTER_CONFIG_DATA_PIN_NUMBER (22U)&lt;/p&gt;
&lt;p&gt;Then it can only talk one channel. Interestingly the twi_sw_master.c doesn&amp;#39;t seem to use NRF_TWI0 or NRF_TWI1 directly. So I&amp;#39;m guessing you&amp;#39;d could make your TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER and TWI_MASTER_CONFIG_DATA_PIN_NUMBER definitions static integers so you can switch them, assuming you only want to chat on one channel at a time. But then you have to remember to keep switching them back and forth which could get messy in your app logic.&lt;/p&gt;
&lt;p&gt;It might be better rewrite the twi_sw_master.c library code so that it takes channel id arguments. For example the macro for TWI_SCL_HIGH() would have to be TWI_SCL_HIGH(TWI0) or TWI_SCL_HIGH(TWI1) which means re-writing this macro :&lt;/p&gt;
&lt;p&gt;#define TWI_SCL_HIGH() do { NRF_GPIO-&amp;gt;OUTSET = (1UL &amp;lt;&amp;lt; TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER); } while(0) /*!&amp;lt; Pulls SCL line high */&lt;/p&gt;
&lt;p&gt;so it takes argument, like this:&lt;/p&gt;
&lt;p&gt;#define TWI_SCL_HIGH(pin) do { NRF_GPIO-&amp;gt;OUTSET = (1UL &amp;lt;&amp;lt; pin); } while(0) /*!&amp;lt; Pulls SCL line high */&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure why they didn&amp;#39;t do all this in the first place... I notice they did support both channels in the spi_master code... so perhaps you can copy that approach essentially each spi* function take a spi_base_address argument. I&amp;#39;d expect all the twi_master* functions to similarly take a TWI channel index. twi_master_init could then take a flag saying which channels you support and it could store a static mapping to your pin definitions which you define like this:&lt;/p&gt;
&lt;p&gt;#define TWI0_MASTER_CONFIG_CLOCK_PIN_NUMBER (23U)
#define TWI0_MASTER_CONFIG_DATA_PIN_NUMBER (22U)&lt;/p&gt;
&lt;p&gt;#define TWI1_MASTER_CONFIG_CLOCK_PIN_NUMBER (24U)
#define TWI1_MASTER_CONFIG_DATA_PIN_NUMBER (25U)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7987?ContentTypeID=1</link><pubDate>Thu, 24 Apr 2014 00:17:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46543efa-1f7b-431b-afb3-3e50067649db</guid><dc:creator>Kris </dc:creator><description>&lt;p&gt;Hello ,&lt;/p&gt;
&lt;p&gt;Are there any example that implement I2C on both the channels (TWI0 &amp;amp; TWI1) ?&lt;/p&gt;
&lt;p&gt;//K&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7982?ContentTypeID=1</link><pubDate>Wed, 19 Mar 2014 11:57:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c18bc67f-3b26-45fa-9481-415fa79aeb3c</guid><dc:creator>ABDELLI-W</dc:creator><description>&lt;p&gt;Thank you so much Chris.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7981?ContentTypeID=1</link><pubDate>Wed, 19 Mar 2014 04:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92c3d5b9-6895-4216-a4e7-3184e608ef6b</guid><dc:creator>Chris Lovett</dc:creator><description>&lt;p&gt;I wrote my own little wrapper that might help, see attached i2c.c.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/i2c.c"&gt;i2c.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7976?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2014 16:19:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d667155a-a6cb-4899-b347-609967d42b35</guid><dc:creator>ABDELLI-W</dc:creator><description>&lt;p&gt;Hi,
Thank you for you Answering.
I&amp;#39;ve seen the example of Nordic, but for me it does not explain very well for me how it implemnts the read/write frame.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7975?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2014 15:33:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc197803-668f-482b-af70-a5a4e360b8ec</guid><dc:creator>Steven Wik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is an example project using I2C on the nRF51822 - they refer to it as a &amp;quot;Two Wire Interface&amp;quot; (TWI) in the PS and RM, please see Section 27 of the RM 2.1 for a complete description.&lt;/p&gt;
&lt;p&gt;The example program of an I2C master can be found in the stack example path below:&lt;/p&gt;
&lt;p&gt;\Nordic Semiconductor\nRF51 SDK_v5.1.0.36092\Nordic\nrf51822\Board\nrf6310\twi_sw_master_example&lt;/p&gt;
&lt;p&gt;Cheers,
Steve&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C example with NRF51822</title><link>https://devzone.nordicsemi.com/thread/7974?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2014 15:29:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33bb7906-380a-4d4e-aeb0-99a54f78bbbb</guid><dc:creator>ABDELLI-W</dc:creator><description>&lt;p&gt;I want to create an I2C Library an dto use it in my sensors. so I  am trying to create write funtion and read function to I2C BUS.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>