<?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>Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8821/hardware-twi-i2c-example</link><description>The latest TWI example I can find is from 4 SDK revisions ago and uses old libraries. Is there a sample using the nrf_drv_twi library that is recommended for current development?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Nov 2015 12:08:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8821/hardware-twi-i2c-example" /><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32411?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2015 12:08:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d937241-2b65-4c40-b7a3-f5a49c64cd0e</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi. @NewToNordic has the answer below. I have updated my initial answer with a step-by-step explanation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32409?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2015 12:07:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:772effd9-7041-4df2-8902-f849e8a4bc14</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi. You were right in your answer below. For the record I&amp;#39;m using Keil uVision (MDK) v5.12.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32412?ContentTypeID=1</link><pubDate>Wed, 25 Nov 2015 21:45:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:066c7c69-f937-48f4-8523-c87b898bc17a</guid><dc:creator>Andrew J.</dc:creator><description>&lt;p&gt;Hey Everyone,&lt;/p&gt;
&lt;p&gt;I believe the issue might lie in the Keil packs for nrf_libraries and nrf_drivers. I used the second newest versions (made in July) with Martin&amp;#39;s new TWI example (V3) and it was able to build.&lt;/p&gt;
&lt;p&gt;Not sure if its the best solution but &lt;strong&gt;it worked.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Thanks,
Andrew&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32410?ContentTypeID=1</link><pubDate>Sun, 22 Nov 2015 16:17:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d232f55-0c34-4712-a4ec-4580ef828085</guid><dc:creator>SDB</dc:creator><description>&lt;p&gt;Hi martin
I want to connect mpu9150 chipset via I2C.
But i can&amp;#39;t find the project what i want.&lt;/p&gt;
&lt;p&gt;I have tested your project.
But i have encountered same problem as  below...&lt;/p&gt;
&lt;p&gt;Build target &amp;#39;nrf51422_xxac&amp;#39;
compiling main.c...
....\main.c(55): warning:  #223-D: function &amp;quot;CONCAT_2&amp;quot; declared implicitly
const nrf_drv_twi_t           p_twi_instance = NRF_DRV_TWI_INSTANCE(1); // Set up TWI instance 1 with default values
....\main.c(55): error:  #20: identifier &amp;quot;NRF_TWI&amp;quot; is undefined&lt;/p&gt;
&lt;p&gt;My MDK version is V5.14&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32408?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2015 22:59:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5a1ce01-7a2b-4d0b-8bab-8e7d40be57e3</guid><dc:creator>Andrew J.</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;What version of MDK are you currently using? I am on 5.17. I was hoping to try 5.16a, the current version when you posted, but I think I have to purchase the full version to do so...&lt;/p&gt;
&lt;p&gt;Could you provide your current configurations (MDK version, SDK version, etc.) or what configurations you know work?&lt;/p&gt;
&lt;p&gt;Thanks,
Andrew&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32407?ContentTypeID=1</link><pubDate>Sun, 15 Nov 2015 00:08:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45714612-5c38-4847-b62f-3e18f37151f4</guid><dc:creator>Andrew J.</dc:creator><description>&lt;p&gt;Thanks Martin. Let me know when it has been resolved.&lt;/p&gt;
&lt;p&gt;Using the method you provided, it appears that I need to add a lot of include paths to make this code work. Still working on it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32406?ContentTypeID=1</link><pubDate>Sat, 14 Nov 2015 19:13:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97fdb21b-510b-47cf-af4c-6e77c7fefedf</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;I tried to run the example myself now and ran into the same problems as you. It looks like there has been an update to the MDK or Keil packs that has messed with what files are included. You need to make sure that it is only the drivers found in &amp;quot;&lt;em&gt;your_SDK9_folder\components&lt;/em&gt;&amp;quot; that is used. Open managed run-time environment in Keil and deselect the TWI drivers there.
I attached an updated example, v3, that works on my system at least. I need to investigate further to find out exactly what caused this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32405?ContentTypeID=1</link><pubDate>Sat, 14 Nov 2015 17:57:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a05282a8-79b7-43e1-9abb-e668b1105ed1</guid><dc:creator>Andrew J.</dc:creator><description>&lt;p&gt;Hi Martin. I believe so.&lt;/p&gt;
&lt;p&gt;C:\Keil_v5\ARM\Device\Nordic\examples\peripheral\twi_simple_SDK9.0.0_v2\pca10028\arm5_no_packs\twi_simple_SDK9.0.0_v2.uvprojx&lt;/p&gt;
&lt;p&gt;*I&amp;#39;m using Dynastream&amp;#39;s N5 Starter kit&lt;/p&gt;
&lt;p&gt;My includes are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;....&lt;/li&gt;
&lt;li&gt;........\bsp&lt;/li&gt;
&lt;li&gt;..........\components\libraries\util&lt;/li&gt;
&lt;li&gt;..........\components\device&lt;/li&gt;
&lt;li&gt;..........\components\toolchain&lt;/li&gt;
&lt;li&gt;..........\components\drivers_nrf&lt;/li&gt;
&lt;li&gt;..............\Pack\ARM\CMSIS\4.5.0\CMSIS\Include&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32404?ContentTypeID=1</link><pubDate>Sat, 14 Nov 2015 08:28:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de34bc64-0edd-4b5c-9a02-efbc5694215e</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Sounds like a path issue. Did you extract the example so that the file path looks exactly like the one in my first comment?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32403?ContentTypeID=1</link><pubDate>Fri, 13 Nov 2015 21:06:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecad4937-fdd0-400c-b30c-42652d4a2239</guid><dc:creator>Andrew J.</dc:creator><description>&lt;p&gt;Hi! I am struggling to build this code. I&amp;#39;m getting errors like:&lt;/p&gt;
&lt;p&gt;....\main.c(55): warning:  #223-D: function &amp;quot;CONCAT_2&amp;quot; declared implicitly
const nrf_drv_twi_t           p_twi_instance =
RF_DRV_TWI_INSTANCE(1); // Set up TWI instance 1 with default values
....\main.c(55): error:  #20: identifier &amp;quot;NRF_TWI&amp;quot; is undefined
const nrf_drv_twi_t           p_twi_instance =&lt;/p&gt;
&lt;p&gt;These appear to be basic TWI macros used by the libraries but definitions for variables like NRF_TWI  cannot be found.&lt;/p&gt;
&lt;p&gt;I am wondering if there is a file path issue that needs to be resolved. Or if this code does not apply to my scenario. I&amp;#39;m using SDK 9.0, nRF51422, Keil_V5, and soft device s110.&lt;/p&gt;
&lt;p&gt;Any suggestions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32397?ContentTypeID=1</link><pubDate>Tue, 01 Sep 2015 08:33:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af512384-9943-4f7b-9319-fc51c829d72e</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;SDK 8 introduced some pretty big changes in the way drivers and libraries are structured so this will require some work (maybe a lot). The main thing to remember, though, is that the SDK 8+ drivers are made for 3rd revision nRF51s and will not work on earlier revisions. If you have a 3rd revision IC and want to use SDK 7.2 I can&amp;#39;t see any reasons why it wouldn&amp;#39;t work if you are willing to do the work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32396?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2015 18:53:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5df7a67d-b25b-4fb8-bcca-62a9fcb28cd3</guid><dc:creator>danbujak</dc:creator><description>&lt;p&gt;I&amp;#39;ve been using your example with 8.1 for a while now and everything seems to be working well, so thank you very much for sample. Do you know if this library would work with SDK 7.2? I know the TWI library that came with that SDK had some issues.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32395?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2015 07:10:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5bac4fd-17ff-43bc-abf8-03c6519e45c1</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;The driver in SDK 9 configures the SDA and SCL pins with internal pullups. However, the pull ups are 13 kOhm, which is quite high, so I would recommend a couple of external ones as well. Especially if you are going to use clock speeds above 100 kHz.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32394?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 14:50:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbca4ef0-62ea-4126-b50d-04d2ab6eec70</guid><dc:creator>danbujak</dc:creator><description>&lt;p&gt;Does this require pull-ups? The SDA line looks like its being pulled up but the SCL isnt&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32402?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 07:28:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3cb2e0f-f9c6-4fa2-bd74-fb01d845191d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Yes, the SDK 9 driver only has a minor bug fix.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32401?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 01:44:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1074f888-c982-4a4d-831f-abce8388d707</guid><dc:creator>danbujak</dc:creator><description>&lt;p&gt;This driver should be compatible with SDK8.1 as well, correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32399?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 09:04:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce44dced-850f-4388-899f-09f818bfa87b</guid><dc:creator>samet kocatepe</dc:creator><description>&lt;p&gt;thanks martin. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32400?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 09:00:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af91a9ae-de97-4e2f-8db1-a3120a172620</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Where did you extract the example? The folder path to your example .uvprojx file should look like this: &lt;em&gt;&amp;quot;your_SDK9_folder\examples\peripheral\twi_simple_SDK9.0.0_v2\pca10028\arm5_no_packs\twi_simple_SDK9.0.0_v2.uvprojx&amp;quot;&lt;/em&gt;. The example is meant to be used with the SDK folder structure in the .zip file &lt;a href="http://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v9.x.x/"&gt;here&lt;/a&gt;. It is not intended for use with the pack installer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32398?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 08:46:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ce7731a-0005-427f-8830-e0022fa60194</guid><dc:creator>samet kocatepe</dc:creator><description>&lt;p&gt;hi martin thank for fast reply.
when i open your example and compile , i faced a build error like image screenshot. can you give any suggest for this.&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Ekran-Alnts.PNG" alt="image description" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware TWI/I2C Example</title><link>https://devzone.nordicsemi.com/thread/32393?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 08:01:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1fd28b0-9f66-4d0c-a0cc-76862dc6f392</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I have made a simple example using the latest TWI driver in SDK 9. It is very basic;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It sets up and configure a TWI instance.&lt;/li&gt;
&lt;li&gt;Transmits dummy bytes to addresses 0x00 to 0x7F and listens for a response from other TWI devices on the bus.&lt;/li&gt;
&lt;li&gt;Lights a LED if a device is found.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I have used this example for a while myself just to get me started on a new TWI project. It is simple, but very handy just to see if you have everything connected and set up correctly.&lt;/p&gt;
&lt;p&gt;Test examples for SDK 0.9.2, 10.0.0, and 11.0.0: &lt;a href="https://github.com/Martinsbl/twi-find-devices-on-bus"&gt;twi-find-devices-on-bus&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/twi_5F00_simple_5F00_SDK9.0.0_5F00_v2.zip"&gt;twi_simple_SDK9.0.0_v2.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;
The folder path to your example .uvprojx file should look like this: &amp;quot;your_SDK9_folder\examples\peripheral\twi_simple_SDK9.0.0_v2\pca10028\arm5_no_packs\twi_simple_SDK9.0.0_v2.uvprojx&amp;quot;. The example is meant to be used with the SDK folder structure in the .zip file here. It is not intended for use with the pack installer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT 2:&lt;/strong&gt; Updated example:
&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/twi_5F00_simple_5F00_SDK9.0.0_5F00_v3.zip"&gt;twi_simple_SDK9.0.0_v3.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT 3:&lt;/strong&gt; Response to the questions and comments below regarding build errors:&lt;/p&gt;
&lt;p&gt;@NewToNordic is right in his answer below. The latest pack driver and library versions are v3.1.0 with e.g. new TWI drivers that are not compatible with the older examples. This is how I solved it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Choose &amp;quot;fixed&amp;quot; from the Selection drop down list.&lt;/li&gt;
&lt;li&gt;Choose version 3.0.1.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1563.Untitled.png" alt="image description" /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you get an error complaining about &amp;quot;nrf_drv_config_validation.h&amp;quot;: No such file or directory, then just comment out the line in nrf_drv_config.h.&lt;/li&gt;
&lt;li&gt;Then finally enable TWI 1 in nrf_drv_config.h by writing &lt;code&gt;#define TWI1_ENABLED 1.&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This worked for me with the 2nd version example in my initial answer and my nRF51 DK kit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>