<?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>Unusual TWI/I2C Problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6431/unusual-twi-i2c-problem</link><description>Hello 
 I&amp;#39;ve been experiencing an unusual problem using the TWI/I2C library for the nRF51-DK board. Basically, I found that I need to shift my device address to the left by 1-bit in order for the board and the device to communicate and I don&amp;#39;t understand</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Apr 2015 12:42:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6431/unusual-twi-i2c-problem" /><item><title>RE: Unusual TWI/I2C Problem</title><link>https://devzone.nordicsemi.com/thread/22407?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2015 12:42:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92c33435-b68b-4b7a-9029-3c7ceae3a0f3</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;It is a sad fact of life that some manufacturers will specify I2C addresses as 0xa0 for write and 0xa1 for read, whereas others use the 7 bit form, which in that case would be 0x50. The safe way is to examine the data-sheet, where there will often be a drawing of the actual waveform/timing diagram.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unusual TWI/I2C Problem</title><link>https://devzone.nordicsemi.com/thread/22406?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2015 10:56:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef1de18c-766c-4928-9aff-ed7c6ef22f63</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;&lt;a href="http://www.i2c-bus.org/addressing/"&gt;www.i2c-bus.org/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The address is 7 bits long, followed by the direction bit. So, you need to shift the address 1 bit left, and then add the direction bit at the end. If it works without shifting the address, it is because the shifting is done in the function you are calling. &lt;code&gt;twi_master_transfer()&lt;/code&gt; (SDK6) does not shift the address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unusual TWI/I2C Problem</title><link>https://devzone.nordicsemi.com/thread/22405?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2015 05:05:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dda5aa55-373b-47ac-8d92-a27810b6fdbd</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;No that&amp;#39;s to be expected. That 0x48 is the 7-bit device address, however if you look at the code for the function you&amp;#39;re using, twi_master_transfer() that uses the 8-bit &amp;#39;address&amp;#39; which is the 7-bit device address followed by a &amp;#39;1&amp;#39; for read or a &amp;#39;0&amp;#39; for write. That&amp;#39;s the address which actually goes out on the wire. That allows you to call one function for both directions of data transfer instead of calling twi_master_read() for read and twi_master_write() for write by using the last bit to figure out which direction you&amp;#39;re going, it then shifts the address back down again and calls either *_read() or *_write().&lt;/p&gt;
&lt;p&gt;So that&amp;#39;s why you need to shift the 7-bit address up by a bit before ORing it with the TWI_READ_BIT&lt;/p&gt;
&lt;p&gt;If you use the twi_master_read() and twi_master_write() functions, those take the 7-bit address because they already know which direction you&amp;#39;re going in.&lt;/p&gt;
&lt;p&gt;So that explains why you have to shift your device address, it&amp;#39;s because of the function you&amp;#39;re calling. My guess would be with the TMP107 you&amp;#39;re calling the read/write functions directly, you haven&amp;#39;t really said exactly what you tested nor which address they are set up for, I believe that chip is configurable for 8 different addresses.&lt;/p&gt;
&lt;p&gt;I know nothing about arduino, but again I&amp;#39;m assuming that there&amp;#39;s a read function and a write function so they take the 7-bit address, or else the function takes an address + a separate read-write flag, so again the address only needs to be the 7-bit one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>