<?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>TWI on nRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63/twi-on-nrf51822</link><description>I just entered a Case to Nordic with this same question but do not expect to get a response over the weekend so I am posting here. I made the assumption that the Nordic Cases and the Developer Zone are not related. If this is considered a double-post</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Aug 2013 09:53:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63/twi-on-nrf51822" /><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/360?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2013 09:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dc38287-5f2f-484d-9d33-7f695adad304</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;To clean things up, I&amp;#39;d be happy if you could evaluate the answers you have received and accept one of them if you feel it&amp;#39;s sufficient. If not, it might be useful to expand your question a little and provide further information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/372?ContentTypeID=1</link><pubDate>Wed, 03 Jul 2013 05:13:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c6db080-4468-415e-be3a-3f0f77987bb0</guid><dc:creator>Tielman</dc:creator><description>&lt;p&gt;Hi Tom&lt;/p&gt;
&lt;p&gt;If the softdevice is enabled, you can not  access the PPI directly as you have done in your code. You have to use the softdevice API to access the PPI. The PPI is mentioned as restricted in the softdevice specification, which means you must access it via the sd API. As example, the following code strip&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_TWI1-&amp;gt;EVENTS_BB;
NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_TWI1-&amp;gt;TASKS_SUSPEND;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;should be replaced by
&lt;code&gt;sd_ppi_channel_assign(0, &amp;amp;NRF_TWI1-&amp;gt;EVENTS_BB, &amp;amp;NRF_TWI1-&amp;gt;TASKS_SUSPEND);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;All the NRF_PPI references need to be replace by sd_ppi_* equivalent  commands.&lt;/p&gt;
&lt;p&gt;I did not notice that your softdevice is enabled (or disabled for that matter) in your code, but the code file you sent is probably a summarized version of your actual code? If you are using BLE in your project, then it is probably enabled in which case you have to modify the code as I have indicated above. As quick reference, simply do the following replacements in your code (with the above example as well):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NRF_PPI-&amp;gt;CHENCLR = PPI_CHENCLR_CH0_Msk;&lt;/code&gt;
should be
&lt;code&gt;sd_ppi_channel_enable_clr(PPI_CHENCLR_CH0_Msk);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_TWI1-&amp;gt;TASKS_STOP;&lt;/code&gt;
should be
&lt;code&gt;sd_ppi_channel_assign(0, &amp;amp;NRF_TWI1-&amp;gt;EVENTS_BB, &amp;amp;NRF_TWI1-&amp;gt;TASKS_STOP);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_TWI1-&amp;gt;TASKS_SUSPEND;&lt;/code&gt;
should be
&lt;code&gt;sd_ppi_channel_assign(0, &amp;amp;NRF_TWI1-&amp;gt;EVENTS_BB, &amp;amp;NRF_TWI1-&amp;gt;TASKS_SUSPEND);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/371?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2013 15:04:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93df9036-e37e-4f30-8649-9502ff962f41</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;There are 8K external pull-ups on both SCL and SDA. The sensor recommends 1.5K - 20K. The Eval Kit board is USB powered and the sensor gets its power for an output pin.&lt;/p&gt;
&lt;p&gt;Yes, the Softdevice is loaded. Is that an issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/366?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2013 10:49:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a15c0586-7993-495b-a828-17de975f4258</guid><dc:creator>Tielman</dc:creator><description>&lt;p&gt;I notice that you initialize your twi master, but don&amp;#39;t check to see if it was successful. Maybe just check that as well. I recently had a I2C device that caused the twi_master_init to fail if the device was not powered before the twi_master_init function was called. Probably not the issue, but still a good habit to check initialization before use.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/367?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2013 10:28:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2c15196-599f-472d-bb00-925c7511164b</guid><dc:creator>Marc Nicholas</dc:creator><description>&lt;p&gt;Is it just me, or does your clock waveform appear to be upside down? Are you sure there&amp;#39;s no polarity issue?&lt;/p&gt;
&lt;p&gt;The waveform of the clock looks about right -- I&amp;#39;m not sure it&amp;#39;s a pull-up issue personally, you would see more of a &amp;quot;saw tooth&amp;quot; waveform if you needed pull-ups IMHO. But I could be completely wrong, so give it a try with 4.7K (or anything you have between 1.5-10K).&lt;/p&gt;
&lt;p&gt;Also, is it possible you have a clocking issue? I haven&amp;#39;t finished my first pot of coffee yet, but on first look I didn&amp;#39;t think you were generating a 400KHz clock...&lt;/p&gt;
&lt;p&gt;Hopefully that might give you some other places to look :)&lt;/p&gt;
&lt;p&gt;-m&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/370?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2013 10:06:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd92959a-4b6f-4230-8610-3d1b3be6c020</guid><dc:creator>Tielman</dc:creator><description>&lt;p&gt;The product specification for the NRF51822 actually specifies the RPU (pull-up resistance) for the GPIO to be about 13k (page 48 of PS v1.3).&lt;/p&gt;
&lt;p&gt;Tom, I do agree with Philip though that 13k might not be enough for many devices and I also typically use 4.7k. I Still suggest that you try external pull-ups and see if you cant get your comms working. If it doesn&amp;#39;t work, then we can dig further.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/369?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2013 08:44:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:038ee7fb-a271-46a4-8329-43028130108e</guid><dc:creator>Philip Freidin</dc:creator><description>&lt;p&gt;Hi Tom,&lt;/p&gt;
&lt;p&gt;It looks like you are relying on the pullup resistors in the nRF51822 for the TWI interface.&lt;/p&gt;
&lt;p&gt;I searched the nRF51822 data sheet and could find nothing about the actual pullup resistor value :(    &lt;em&gt;See Tielman&amp;#39;s reply to my post, I should have been looking in the Product Spec, not the Reference Manual&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In my experience, these values tend to be any where from 10K to 200K in other products. When I design TWI (I2C) interfaces, I typically use 4.7K . If the pullup resistor is too high a resistance (which may be true in your case), then the rising edges on SDA and SCL can be too slow, and it may not rise to a valid logic high. You SDA_SDL_2.jpg picture certainly suggests this.&lt;/p&gt;
&lt;p&gt;If your devices have different power rails, such as 2.5 V for one device and 3.0 for the other, the pull up resistors should connect to the higher rail. This won&amp;#39;t work if there is significant difference (2.5V and 5V), in which case you need a level shifter as well as the pullup resistors.&lt;/p&gt;
&lt;p&gt;Cheers,
Philip&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/368?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2013 03:07:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39d4da26-c0f9-45d0-b1e7-7fd314636e64</guid><dc:creator>Tielman</dc:creator><description>&lt;p&gt;Hi Tom&lt;/p&gt;
&lt;p&gt;Have you by any chance got the Softdevice loaded onto your device?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/365?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2013 21:46:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14618f30-bbf8-4605-856c-c80be57be74c</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;Attached are the latest waveforms and revised code showing port initialization. I found a wiring error to the sensor (no power) but still is not working. Apparently the TX is not completing because it always exits the following command in twi_master_write() with timeout = 0. Five CLK&amp;#39;s are issued but no SDA.&lt;/p&gt;
&lt;p&gt;while(NRF_TWI1-&amp;gt;EVENTS_TXDSENT == 0 &amp;amp;&amp;amp; (--timeout));  // HANGING HERE (TIMEOUT ALWAYS 0)&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SDA_2D00_SCL-4.jpg" alt="SDA-SCL 4.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SDA_2D00_SCL-5.jpg" alt="SDA-SCL 5.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/twi.txt"&gt;twi.txt&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/364?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2013 06:20:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1c07a80-8eed-49fe-a8b9-debd72838941</guid><dc:creator>Tielman</dc:creator><description>&lt;p&gt;Hi Tom&lt;/p&gt;
&lt;p&gt;What is the supply to your system? From the graphs you sent, the SDA line goes to about 2.4V while the CLK only rises to about 1.3V. According to the datasheet of your TWI device, you need a supply of at least 2.6V and that comms should go up to 2.5V. Comms will definitely not work.
Will you also send the pin configuration of your TWI lines? I do not see them in the code. Please note that according to Figure 15 in the nrf51822 Ref Manual, it appears that the pull configuration is only used when the pin has the input buffer enabled. Not sure if the pull-up is used when configured as output?
Have you connected two external resistors to your comms lines to see if you can at least get comms to work to your device first? Maybe give this a try if you have not yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/361?ContentTypeID=1</link><pubDate>Sat, 29 Jun 2013 19:16:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5302ad3-8a1e-45e9-ac2f-f11ad25420f9</guid><dc:creator>Marc Nicholas</dc:creator><description>&lt;p&gt;I can see the problem: your waveforms look exactly like the nRF51822 data sheet!&lt;/p&gt;
&lt;p&gt;(I think you attached the wrong file...)&lt;/p&gt;
&lt;p&gt;-m&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/363?ContentTypeID=1</link><pubDate>Sat, 29 Jun 2013 18:44:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92a772e0-94b7-461a-a735-5bf3a93578e4</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;Attached are the SCL (yellow) and SDA (blue) waveforms. The difference between the 3 traces is the timebase.&lt;/p&gt;
&lt;p&gt;After starting SCL runs continuously. SDA looks completely wrong so there is something major wrong. The slow risetime of SDA implies there may not be a pullup but I have enabled the on-chip pullups (none external) for SCL and SDA. I appears that both SCL and SDA go low nearly simultaneously (much less than 20ns apart).&lt;/p&gt;
&lt;p&gt;I misunderstood youe question and uploaded the nRF51822 rather than the slave device. I thought that was an unusual request. :)&lt;/p&gt;
&lt;p&gt;This forum is very particular about what file types can be attached. I attached the waveforms in BMP format and apparently they are not allowed. Here they are after converting to JPG.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SDA_2D00_SCL-1.jpg" alt="SDA-SCL 1.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SDA_2D00_SCL-2.jpg" alt="SDA-SCL 2.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SDA_2D00_SCL-3.jpg" alt="SDA-SCL 3.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/MLX90325.pdf"&gt;MLX90325.pdf&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI on nRF51822</title><link>https://devzone.nordicsemi.com/thread/362?ContentTypeID=1</link><pubDate>Sat, 29 Jun 2013 13:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9cbb003-eec6-42af-a6ed-8d74f1bd2c84</guid><dc:creator>Marc Nicholas</dc:creator><description>&lt;p&gt;Hi Tom,&lt;/p&gt;
&lt;p&gt;Are you able to share the datasheet of the device you&amp;#39;re working with?&lt;/p&gt;
&lt;p&gt;Also, it sounds like you have a logic analyzer hooked-up (which is a Good Thing(tm)) -- are you seeing SCL go low &lt;em&gt;after&lt;/em&gt; SDA goes low? i.e. an I2C/TWI start sequence?&lt;/p&gt;
&lt;p&gt;The timing and pattern is important, so you&amp;#39;ll want to capture both synchronously if you can.&lt;/p&gt;
&lt;p&gt;See the attached image URL for details.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll go through your code, but I&amp;#39;m also experimenting with I2C, so may not be much help :p&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;-m&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>