<?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 Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6861/twi-module-lock-up-still-present-in-nrf51822-v3-pan-56</link><description>Hi, 
 I am currently experiencing TWI module lock-up issues with the hardware TWI library, which is supposedly fixed according to PAN v3.0, issue #56. (The issue was previously identified in PAN v2.3) 
 My setup is as follows, custom board, SD110v8</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Jun 2015 07:39:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6861/twi-module-lock-up-still-present-in-nrf51822-v3-pan-56" /><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24184?ContentTypeID=1</link><pubDate>Tue, 09 Jun 2015 07:39:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb193649-80e9-4142-b9f0-d4de0195eec4</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;Hi RK, thanks for the reply as always. At this point we don&amp;#39;t have the resource to investigate this further. I will just use the library that is working for us at the moment. Cheers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24183?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 00:50:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf9a2537-bf3e-49bf-901f-349bace6e408</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;I have no real idea because I don&amp;#39;t use it - I write all my own library code. That said, 100s of products have been shipped using Nordic&amp;#39;s TWI HW library and they appear to work and I&amp;#39;m guessing from the name of the thing you found, tw_hw_master.c, that it&amp;#39;s a derivative of, or an earlier version of, the HW library.&lt;/p&gt;
&lt;p&gt;In the end it&amp;#39;s hard to see how a HW library could work intermittently, it&amp;#39;s hardware, you write the register, the byte is clocked in and/or out, the clock is togged, in hardware. The TWI hardware either works or it doesn&amp;#39;t, there&amp;#39;s not much you can do to drive it which will make it work differently.&lt;/p&gt;
&lt;p&gt;The only thing I can say about those traces (and I&amp;#39;m spoiled as I have a logic analyser which make life easier) is that the nrf TWI appears to do the right thing but there&amp;#39;s no reply from the other chip. I think if you want to get further perhaps file a support case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24182?ContentTypeID=1</link><pubDate>Tue, 02 Jun 2015 14:05:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00c93b64-0465-4f10-bc1a-5985f2e9aafd</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;hi RK, apologies for the late reply again, been tied up with some other work and havent got the time to investigate this.&lt;/p&gt;
&lt;p&gt;I took out the oscilloscope and started probing the I2C bus. What I have discovered is:&lt;/p&gt;
&lt;p&gt;using the PACK SW library, no issues observed
using the PACK HW library, occasional issue observed (no NACK received, the SDA is not held low)
using a custom HW library, which I found from one of the other posts, no issues observed&lt;/p&gt;
&lt;p&gt;I will include the screenshots I have took too&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Pack_5F00_SW_5F00_Working.png"&gt;1 - PACK SW working&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Pack_5F00_HW_5F00_Working.png"&gt;2 - PACK HW Working&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Pack_5F00_HW_5F00_Error.png"&gt;3 - PACK HW error&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Custom_5F00_HW_5F00_Working.png"&gt;4 - Custom HW working&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Also, this is the custom HW TWI library that I have used.
&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/twi_5F00_hw_5F00_master.c"&gt;twi_hw_master.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Judging from the screenshots, SW has slightly different timing for the SCL, which is expected.&lt;/p&gt;
&lt;p&gt;When the PACK HW library is working, it looks identical to the custom HW library (compare 2 with 4).&lt;/p&gt;
&lt;p&gt;However, when the PACK HW library is not working, I can also confirm that SDA is not held low during the NACK bit.&lt;/p&gt;
&lt;p&gt;I did a quick comparison between the custom HW .c file and the PACK HW .c file, there are quite a few differences, which lead me to think, there might be an issue with the existing HW library in the PACK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24181?ContentTypeID=1</link><pubDate>Thu, 21 May 2015 05:46:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35d549ad-095a-4aeb-a9c9-57d87a3ad6df</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;I don&amp;#39;t know - I haven&amp;#39;t used the sw master, actually I haven&amp;#39;t used the hw master either :) but I just looked at it, wow, it&amp;#39;s an old bit banger. I would say that&amp;#39;s going to have somewhat different timing than the real hardware interface, it seems from looking at the code quite .. generous about timings. I&amp;#39;d check the speed you&amp;#39;re running the I2C at, perhaps try something slower, check all the parameters too, I assume those two things are supposed to be API compatible but check everything.&lt;/p&gt;
&lt;p&gt;One last thought, make sure that EVENTS_ERROR isn&amp;#39;t already set from something previous before you start the transfer. I have no idea whether starting a new transfer clears it if set, if not, you may be instantly failing because it was set previously. I don&amp;#39;t see in the code anywhere it&amp;#39;s cleared.&lt;/p&gt;
&lt;p&gt;Failing that - it&amp;#39;s logic analyser time to see what&amp;#39;s actually being written in each case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24178?ContentTypeID=1</link><pubDate>Wed, 20 May 2015 14:14:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf53eba3-36d6-4802-a7a9-c751a6ed8859</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;hi RK, thanks for the feedback as always. if the hw twi driver is experiencing the NAK issue, why would the sw twi driver work without any issue in this case? (after selecting the software option in the twi driver, i can talk to my i2c device without any issue)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24180?ContentTypeID=1</link><pubDate>Wed, 20 May 2015 12:23:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e2b6bfb-a22b-465c-bbb7-af595dd90592</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Ah ok - so I don&amp;#39;t think that is the lockup then. AFAIR the lockup meant exactly that, nothing happened, the character was never sent, there was no error, it just locked up and you never heard from it again.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s what timeout-- did, it polled for a certain amount of cycles beyond which &lt;em&gt;something&lt;/em&gt; should have happened and when it didn&amp;#39;t, it reset the chip. So if it locked up eventually it would fail and reset.&lt;/p&gt;
&lt;p&gt;In your case however you&amp;#39;re not dropping into that code because timeout has hit zero, but because TWI has reported an error, the second piece of that 3-part if() statement. In this case it&amp;#39;s 0x02 which is ANACK, a NAK was received after sending out the address. So the address went out and the peripheral you were trying to talk to didn&amp;#39;t hold the data line low during the next clock period.&lt;/p&gt;
&lt;p&gt;Good news, seems unlikely to be the lockup, bad news, time to get the logic scope out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24179?ContentTypeID=1</link><pubDate>Wed, 20 May 2015 11:41:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd15d93e-23ea-4a8b-8679-eaa611e4a40d</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;hi all, my apologies for not getting back to you sooner&lt;/p&gt;
&lt;p&gt;the trigger is NRF_TWI1-&amp;gt;EVENTS_ERROR = 1. the NRF_TWI1-&amp;gt;ERRORSRC value is 0x02.&lt;/p&gt;
&lt;p&gt;I have already submitted a case through mypage, and uploaded the firmware in a .zip file&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24177?ContentTypeID=1</link><pubDate>Wed, 06 May 2015 13:47:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80f35423-b814-44eb-8188-eb5e198a4fad</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi Mike. Are you able to answer RK&amp;#39;s question? And also what modifications did you do to the original example?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24173?ContentTypeID=1</link><pubDate>Wed, 06 May 2015 07:22:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6742a39-f6a6-4327-9dc9-679b7527a63c</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Hence my question - that while loop can still be exited by either&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The character send completing&lt;/li&gt;
&lt;li&gt;The error event being triggered (ie becoming non-zero)&lt;/li&gt;
&lt;li&gt;The timeout reaching zero&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I asked which of 2. or 3. actually caused the loop to exit. If it was an ERROR being indicated as opposed to the timer counting down to zero, then it&amp;#39;s just a TWI error being reported and not the &amp;#39;lockup&amp;#39;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24176?ContentTypeID=1</link><pubDate>Wed, 06 May 2015 07:11:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a19e47e-42e1-49af-8cf7-cdc2208b9eb5</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;There is a while loop right above the code Mike posted:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;while (NRF_TWI1-&amp;gt;EVENTS_TXDSENT == 0 &amp;amp;&amp;amp; NRF_TWI1-&amp;gt;EVENTS_ERROR == 0 &amp;amp;&amp;amp; (--timeout))
 {
       // Do nothing.
 }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;@Mike: I am still invastigating this. But let me make myself clear: in the myPage portal you will get &lt;em&gt;complete&lt;/em&gt; confidentiality, not &lt;em&gt;some&lt;/em&gt; as I wrote above. Customers use myPage to upload their code and designs all the time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24175?ContentTypeID=1</link><pubDate>Wed, 06 May 2015 04:11:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfd70d66-96a9-4ee5-8eb8-63cf6158529b</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;which is the condition causing the code to enter the segment? timeout==0 or EVENTS_ERROR is non-zero?&lt;/p&gt;
&lt;p&gt;What is NRF_TWI1-&amp;gt;ERRORSRC ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24174?ContentTypeID=1</link><pubDate>Wed, 06 May 2015 04:01:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:429dad29-3903-4c1c-a760-a4550089775d</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;@Martin and @RK, I will try to provide some information before resulting to upload the code, as I have to check with my colleagues about confidentiality.&lt;/p&gt;
&lt;p&gt;I would say out of all the function calls to twi_master_write function, the error rate can be as high as 50%, or as low as 10%, fairly irregular in when it appears too. The function is called once every 2s (in the battery_meas_timeout_handler function).&lt;/p&gt;
&lt;p&gt;I debugged the code, and identified that the code enters this particular segment when an error occurs:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    if (timeout == 0 || NRF_TWI1-&amp;gt;EVENTS_ERROR != 0)
    {
        // Recover the peripheral as indicated by PAN 56: &amp;quot;TWI: TWI module lock-up.&amp;quot; found at
        // Product Anomaly Notification document found at 
        // &lt;a href="https://www.nordicsemi.com/eng/Products/Bluetooth-R-low-energy/nRF51822/#Downloads"&gt;www.nordicsemi.com/.../&lt;/a&gt;
        NRF_TWI1-&amp;gt;EVENTS_ERROR = 0;
        NRF_TWI1-&amp;gt;ENABLE       = TWI_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; TWI_ENABLE_ENABLE_Pos; 
        NRF_TWI1-&amp;gt;POWER        = 0;
        nrf_delay_us(5);
        NRF_TWI1-&amp;gt;POWER        = 1;
        NRF_TWI1-&amp;gt;ENABLE       = TWI_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; TWI_ENABLE_ENABLE_Pos;

        (void)twi_master_init();

        return false;
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another interest point is, if the battery_meas_timer is the only one running (before the bootloader starts to advertise, this problem doesnt seem to happen, however once the other app_timer tasks starts, such as ble_advertising (and I think there is one for bootloader timeout), this problem starts happening.&lt;/p&gt;
&lt;p&gt;Please let me know if this is sufficient information for you, otherwise I will try to get permission to upload some code for you. Cheers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24172?ContentTypeID=1</link><pubDate>Mon, 04 May 2015 15:37:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:109c0460-6c7a-489b-bc6f-2d7055f8713f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Mike - if the version of the .c file you&amp;#39;re using is the same as the one posted as you say, then the issue you&amp;#39;re having cannot be the PAN from the previous silicon revision, that twi driver works around that issue. So you certainly have a problem which may look like the hardware TWI lockup, but it can&amp;#39;t be the same thing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24171?ContentTypeID=1</link><pubDate>Mon, 04 May 2015 14:42:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:692a2f67-7392-489d-8eb8-64ecc7e5bc27</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Ah, sorry for the misunderstanding.
We haven&amp;#39;t had any reports on TWI lockups on rev 3 silicon, so this is new to us and we suspect there might be something going on during dfu.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Do you have access to a logic analyzer to show us what is going on on the TWI lines?&lt;/li&gt;
&lt;li&gt;Can you share your code with us? You can contact us on our MyPage support portal if you prefer some confidentiality.&lt;/li&gt;
&lt;li&gt;Are you able to debug the code to see if your code hangs somewhere?&lt;/li&gt;
&lt;li&gt;When you say &amp;quot;the TWI transaction would randomly occur, fairly frequently&amp;quot; do you mean that the lockup randomly occur or is the TWI really going haywire?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24169?ContentTypeID=1</link><pubDate>Mon, 04 May 2015 14:08:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:903d9a26-d270-484b-8d00-38b9f50b1520</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;RK&amp;#39;s comments pretty much covered everything for me (thanks!)&lt;/p&gt;
&lt;p&gt;@Martin, by the way, the .c file you posted is the same as the one I used.&lt;/p&gt;
&lt;p&gt;As mentioned previously, I am curious why the lock up still happens. According to PAN v3.0, this issue should be fixed in hardware in the v3 silicons.&lt;/p&gt;
&lt;p&gt;Thanks, Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24170?ContentTypeID=1</link><pubDate>Mon, 04 May 2015 13:19:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5311e793-259b-4ca4-9b75-d1229379f36a</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;I don&amp;#39;t think that was his question, he didn&amp;#39;t want a TWI driver which worked around PAN 56, he was saying that the latest revision 3 chipset was supposed to have fixed PAN 56 in hardware, thus not requiring a driver which worked around the issue because there should no-longer be an issue to work around.&lt;/p&gt;
&lt;p&gt;Does revision 3 hardware still suffer from TWI lockup? The original poster is saying that he&amp;#39;s seeing something very like the pre-revision 3 TWI hardware lockup on revision 3 hardware.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module lock-up still present in nrf51822 v3 [PAN #56]</title><link>https://devzone.nordicsemi.com/thread/24168?ContentTypeID=1</link><pubDate>Mon, 04 May 2015 12:32:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed9a66ce-3b10-4c18-bbdb-8028a9c5a429</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi. Which TWI driver are you using. I&amp;#39;m afraid that there are a couple of different versions out there. I have attached the TWI hardware driver included in SDK v8 which is supposed to have corrected for PAN 56.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5468.twi_5F00_hw_5F00_master.c"&gt;twi_hw_master.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>