<?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>Using Nrf51422 as I2C(TWI)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10576/using-nrf51422-as-i2c-twi</link><description>Hello 
 I have an problem using I2C on my custom board which uses an Nrf51422 SOC.
I have an RTC chip connected to it and I have no idea how to use your libraries. 
 The rtc 7 bit slave address is 0xDE. And they have registers which needs to be accessed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Dec 2015 11:26:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10576/using-nrf51422-as-i2c-twi" /><item><title>RE: Using Nrf51422 as I2C(TWI)</title><link>https://devzone.nordicsemi.com/thread/39342?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2015 11:26:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24b3ded2-e98c-4a40-88cc-0c61efbbfe87</guid><dc:creator>Darshan</dc:creator><description>&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;I followed your procedure and did the same for read. And I am not able to read in debug mode.&lt;/p&gt;
&lt;p&gt;ALL the pins are connected properly double checked the PCB with my schematics. And the slave is responding have an LED for response which glows.&lt;/p&gt;
&lt;p&gt;please find my code and read cycle attached in my previous answer above.&lt;/p&gt;
&lt;p&gt;can you help me for READ CYCLE ??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Nrf51422 as I2C(TWI)</title><link>https://devzone.nordicsemi.com/thread/39341?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2015 10:51:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:946f5153-e5e0-46be-bbc0-534d953ae621</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;I don&amp;#39;t use it but .. it must be something like this&lt;/p&gt;
&lt;p&gt;Your slave address is 0xDE, you said, that&amp;#39;s the pre-shifted one, Nordic uses just the 7 bits, so it&amp;#39;s 0xDE &amp;gt;&amp;gt; 1 or 0x6F. That diagram shows a standard I2C transaction (you should read the spec) so the first byte is the address, shifted, finishing with a &amp;#39;0&amp;#39; which means &amp;#39;write&amp;#39;.&lt;/p&gt;
&lt;p&gt;So assuming you want to write 0x12 to the register with address 0x20 and you&amp;#39;ve set the TWI up already&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t data[2]; // should be a static buffer especially if you&amp;#39;re using the callback mode
data[0] = 0x20;
data[1] = 0x12
nrf_drv_twi_tx( &amp;amp;instance, 0x6F, data, 2, xfer_pending );
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;instance is the instance you set up, xfer_pending depends on what you&amp;#39;re doing (ie are you going to do a repeated start to read data back). That writes out the address and two bytes of data to TWI.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Nrf51422 as I2C(TWI)</title><link>https://devzone.nordicsemi.com/thread/39340?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2015 10:05:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1ce228b-72df-42e3-8d42-8a4578153121</guid><dc:creator>Darshan</dc:creator><description>&lt;p&gt;Thank you ,&lt;/p&gt;
&lt;p&gt;Can you please explain me with a few steps for write operations using nrf_drv_twi_tx(); functions?
I have attached the screenshot of byte write sequence as per the datasheet .&lt;/p&gt;
&lt;p&gt;SRAM in I2C register starts from 0x20;
and SLAVE/DEVICE ADDRESS is 1101111 or 0x6F.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/byte-write.PNG"&gt;byte write.PNG&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;control byte is READ/WRITE.&lt;/p&gt;
&lt;p&gt;ADDRESS BYTE is slave register.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/I2c-code.txt"&gt;I2c code.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;READ CYCLE&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/byte-read.PNG"&gt;byte read.PNG&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;RTC DATASHEET&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/rtc-chip-smart-switch.pdf"&gt;rtc chip smart switch.pdf&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Nrf51422 as I2C(TWI)</title><link>https://devzone.nordicsemi.com/thread/39343?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2015 08:59:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f92174c-9e34-4702-8644-9e979ee0cf7f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;The nrf_drv_twi_tx() function doesn&amp;#39;t have registers because registers isn&amp;#39;t anything to do with the actual I2C protocol. I2C is just a data read/data write protocol which does exactly that, writes a chunk of data to a device at an address and reads data back from a device at an address.&lt;/p&gt;
&lt;p&gt;The chip you&amp;#39;re interfacing with may be explained in the datasheet using registers, but if you read it again you should see the underlying basic I2C data transfer which accesses them is just a data transfer with a given format. Often for instance, the &amp;#39;register&amp;#39; number you&amp;#39;re writing to is the first byte of the data transferred, and the rest of the data is what&amp;#39;s then written to that &amp;#39;register&amp;#39;. A transfer may consist of writing a byte with a register number in the written data, and then reading, the chip then sends the contents of that &amp;#39;register&amp;#39; out.&lt;/p&gt;
&lt;p&gt;Once you&amp;#39;ve understood the basic command sequence to your RTC chip and know how to format the data, then you&amp;#39;ll see the function above is exactly what you need, it just sends out a chunk of formatted data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>