<?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 protocol.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/530/i2c-protocol</link><description>Dear Sir, 
 i am using pca10001. 
 Actually i tried to read and write the data from EEPROM having address 0x50 though i2cbus. 
 i made po.0 and p0.1 as output pin then clk and sda pin respectively. 
 i done every thing. but once i start NWF_TWI0-</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 14 Dec 2013 10:40:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/530/i2c-protocol" /><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2760?ContentTypeID=1</link><pubDate>Sat, 14 Dec 2013 10:40:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52215b3a-7ed7-46f6-8be0-1a0d6b92d5b3</guid><dc:creator>John Kelley</dc:creator><description>&lt;p&gt;0x18 is 24 in hexadecimal format&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2765?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2013 08:52:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:582b7b99-ab9d-4d8c-8414-937c43581b58</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;Hi rangineni,&lt;/p&gt;
&lt;p&gt;i am not able to see your photos.&lt;/p&gt;
&lt;p&gt;before writing data , try by reading device id.&lt;/p&gt;
&lt;p&gt;Regards
Balaji&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2766?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2013 08:52:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:785610ad-a38c-4df8-92df-cc7fba7fc345</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;Hi rangineni,&lt;/p&gt;
&lt;p&gt;i am not able to see your photos.&lt;/p&gt;
&lt;p&gt;before writing data , try by reading device id.&lt;/p&gt;
&lt;p&gt;Regards
Balaji&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2764?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2013 06:09:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57755f33-ded8-4b76-818c-b11d21b89ed3</guid><dc:creator>rangineni balu</dc:creator><description>&lt;p&gt;hi balaji thanks for you replies, but still i am not able to read the data&lt;/p&gt;
&lt;p&gt;&lt;img src="https://plus.google.com/photos/yourphotos?hl=en&amp;amp;partnerid=gplp0&amp;amp;pid=5941153641244864610&amp;amp;oid=104726538030265079264" alt="https://plus.google.com/photos/yourphotos?hl=en&amp;amp;partnerid=gplp0&amp;amp;pid=5941153641244864610&amp;amp;oid=104726538030265079264" /&gt;&lt;/p&gt;
&lt;p&gt;check that image once, at the time of debuggig i got this one, the working of every register of twi in nrf51822&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2763?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2013 13:51:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ffc62dc-af09-46e8-b545-6366a947edc4</guid><dc:creator>balaji</dc:creator><description>&lt;p&gt;Can you what is 7 bit address of Sensor.&lt;/p&gt;
&lt;p&gt;and tried with&lt;/p&gt;
&lt;p&gt;uint8_t addr=7bitaddress ;
uint8_t addW=(addr&amp;lt;&amp;lt;1);
uint8_t addR=(addr&amp;lt;&amp;lt;1)|0x01;
uint8_t dataW[2] = {0X03, 0x83};
uint8_t dataR[2]={0x00}&lt;/p&gt;
&lt;p&gt;twi_master_init()
twi_master_transfer(addW,dataW,2,1);
nrf_delay_us(400);
twi_master_transfer(addW,&amp;amp;dataW[0],1,0);
nrf_delay_us(400);
twi_master_transfer(addR,dataR,1,1);
nrf_delay_us(400);&lt;/p&gt;
&lt;p&gt;check 0x03 is read only register or R/W register.&lt;/p&gt;
&lt;p&gt;Regards
Balaji&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2762?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2013 13:33:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:522728c0-bf47-444c-87fd-cad2f90d5b96</guid><dc:creator>rangineni balu</dc:creator><description>&lt;p&gt;uint8_t addw = 0x39;  // address of the device
bool f_t = false;
uint8_t dataW[2] = {0X03, 0x83};   // commands&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t addr = (0x39 | 0x01);
uint8_t dataR[2] = {0x00, 0x00}; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;if(twi_master_init())
{&lt;/p&gt;
&lt;p&gt;f_t =  twi_master_transfer(addw, &amp;amp;dataW[0], 1 , true);&lt;/p&gt;
&lt;p&gt;nrf_delay_ms(1000);&lt;/p&gt;
&lt;p&gt;f_t =  twi_master_transfer(addw, &amp;amp;dataW[1], 1 , true);&lt;/p&gt;
&lt;p&gt;nrf_delay_ms(1000);&lt;/p&gt;
&lt;p&gt;f_t = twi_master_transfer(addr, dataR, 1, true);&lt;/p&gt;
&lt;p&gt;f_t -  is just for debugging purpose to check the return value  - true / false&lt;/p&gt;
&lt;p&gt;every tme i am getting f_t as ZERO, that means transfer fails!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2761?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2013 13:25:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99305db0-0a35-4c7d-8739-e7552fba7abb</guid><dc:creator>balaji</dc:creator><description>&lt;p&gt;i tried with accelerometer sensor. when i give delay its working fine.&lt;/p&gt;
&lt;p&gt;if you send code it will be easy to find fault.&lt;/p&gt;
&lt;p&gt;Regards
Balaji&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2759?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2013 13:17:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c3f6b2b-df0f-4e25-b61b-d66368f2c150</guid><dc:creator>rangineni balu</dc:creator><description>&lt;p&gt;I did that one, i am giving 1 sec delay b/w write and read,
while debugging, the PSELSCL = 0X00000018,  PSELSDA = 0X00000019&lt;/p&gt;
&lt;p&gt;showing the pin numbers as 18 and 19, but my actual pins i am using are -&lt;/p&gt;
&lt;p&gt;#define TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER (24U)
#define TWI_MASTER_CONFIG_DATA_PIN_NUMBER (25U)&lt;/p&gt;
&lt;p&gt;24 and 25, why it is showing like that ?&lt;/p&gt;
&lt;p&gt;even i tried to connect to the 18 and 19 pins but not getting any thing!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2758?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2013 12:58:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:726b9ed1-f1a3-4f87-abf6-6a54ceaa2379</guid><dc:creator>balaji</dc:creator><description>&lt;p&gt;Tried with Keeping delay of max 400us. after every write and read.&lt;/p&gt;
&lt;p&gt;and also check with both debugging mode and by single run.&lt;/p&gt;
&lt;p&gt;if it does not work,check you are passing correct device id or not.&lt;/p&gt;
&lt;p&gt;Regards
Balaji&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2757?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2013 12:36:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93bef239-ecc0-482b-9653-ee5e134e2ac7</guid><dc:creator>rangineni balu</dc:creator><description>&lt;p&gt;hi, i tried your approach above shown, but i was not able to read the data from the sensor, here in my case i am integrating sensor instead of EEPROM, i tried both hw and sw TWI&lt;/p&gt;
&lt;p&gt;ERRORSRC=2 and EVENTS_ERROR=1.&lt;/p&gt;
&lt;p&gt;me too got the same while debugging, what might be the problem....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2c protocol.</title><link>https://devzone.nordicsemi.com/thread/2756?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2013 13:47:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16179a3c-0c16-4c8b-8df0-1c34d90de9a4</guid><dc:creator>Gabriele</dc:creator><description>&lt;p&gt;Hi, you can have a look at the twi_hw_master.c example in the sdk folder. I&amp;#39;ve just used that functions to communicate with a Microchip EEPROM (according to I2C address i imagine it&amp;#39;s the same are using you, maybe just the size is different).
Follow the snippets of code to write EEPROM:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
uint8_t addw = 0xa0;
uint8_t dataW[3] = {0x5d, 0x00, 0xfb};
if(twi_master_transfer(addw, dataW, 3, true))
	simple_uart_putstring((const uint8_t *)&amp;quot; \n\rOK\n\r&amp;quot;);
else
	simple_uart_putstring((const uint8_t *)&amp;quot; \n\rERROR\n\r&amp;quot;);

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And to read the EEPROM:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
uint8_t addr = 0xa1;
uint8_t dataR[2] = {0x5d, 0x00};
//	Writing device address and register
twi_master_transfer(addw, dataW, 2, true);
//	Writing device address and reading data
twi_master_transfer(addr, dataR, 1, true);

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A little explanation, if the EEPROM address is 0x50, you have to left shift one position and add 1 to read bytes, and simply left shift to read, so 0x50 become 0xA0 to write and 0xA1 to read from the EEPROM. Register address is two bytes long (if the EEPROM is bigger than 65KB, look at the datasheet of your model), in my examples i am writing the value 0xFB to the register 0x5D00, then i read the value from the same register. If you go in debug mode and watch the dataR first element, you should find the correct value after reading... i hope it helps!
Ops, i forgot to say... for that example SCL and SDA are the pins 24 and 25 of pca10001 ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>