<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis MicrocontrollersのトピックI2C SDA Lockup after arbitration loss</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422159#M24176</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After solving another problem on arbitration loss detection for Kinetis I2C modules, I am stuck with a very serious problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am writing an I2C low level driver for multimaster operation in a FRDM-K64F board, and to test it I am emulating data collisions using another K64 board, through "bit-bang" approach. The emulation board works nice, it tests all conditions I want to test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, I keep flooding the bus with repeated start data until I press a button to release the bus, forcing my driver to wait for the bus release to send its data. This is working fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, it waits for my driver to issue a START and then sends data to the same ID (and EEPROM sharing the same bus), but the first data byte of my emulating board has higher priority, and so my driver has to detect arbitration loss and let the emulator finish its transfer. It also works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The final test is the problem: the emulator waits for the START again, and then sends the slave ID of my driver (0x20), which has higher priority than the ID that the driver is sending (0x50 for the EEPROM). Thus, the driver should recognize bôth arbitration loss and slave ID match. Both conditions are recognized at the respective flags in the Status register, but when I try to clear the TX bit at the Control 1 register (I2C1_C1) to put the module in receive state, it locks the SDA line to Low. I should not happen, I would understand that it could lock if I was changing from RX to TX, but not the opposite way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know what wrong I am doing. Any clues?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Antonio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Aug 2015 19:46:59 GMT</pubDate>
    <dc:creator>quevedo</dc:creator>
    <dc:date>2015-08-06T19:46:59Z</dc:date>
    <item>
      <title>I2C SDA Lockup after arbitration loss</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422159#M24176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After solving another problem on arbitration loss detection for Kinetis I2C modules, I am stuck with a very serious problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am writing an I2C low level driver for multimaster operation in a FRDM-K64F board, and to test it I am emulating data collisions using another K64 board, through "bit-bang" approach. The emulation board works nice, it tests all conditions I want to test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, I keep flooding the bus with repeated start data until I press a button to release the bus, forcing my driver to wait for the bus release to send its data. This is working fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, it waits for my driver to issue a START and then sends data to the same ID (and EEPROM sharing the same bus), but the first data byte of my emulating board has higher priority, and so my driver has to detect arbitration loss and let the emulator finish its transfer. It also works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The final test is the problem: the emulator waits for the START again, and then sends the slave ID of my driver (0x20), which has higher priority than the ID that the driver is sending (0x50 for the EEPROM). Thus, the driver should recognize bôth arbitration loss and slave ID match. Both conditions are recognized at the respective flags in the Status register, but when I try to clear the TX bit at the Control 1 register (I2C1_C1) to put the module in receive state, it locks the SDA line to Low. I should not happen, I would understand that it could lock if I was changing from RX to TX, but not the opposite way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know what wrong I am doing. Any clues?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Antonio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2015 19:46:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422159#M24176</guid>
      <dc:creator>quevedo</dc:creator>
      <dc:date>2015-08-06T19:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: I2C SDA Lockup after arbitration loss</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422160#M24177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Antonio:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a published &lt;A href="http://cache.freescale.com/files/microcontrollers/doc/errata/KINETIS_1N83J.pdf"&gt;errata&lt;/A&gt; concerning I2C arbitration in K64 (mask 1N83J):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/55255i6C7761F1D4EAA553/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From a previous post I think you are using Processor Expert, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, then this might explain that behavior. Try with the workaround of clearing the &lt;STRONG&gt;MST&lt;/STRONG&gt; bit before clearing th e &lt;STRONG&gt;ARB&lt;/STRONG&gt; bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Aug 2015 01:36:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422160#M24177</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2015-08-07T01:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: I2C SDA Lockup after arbitration loss</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422161#M24178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Hello Jorge,&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;I tried switching to SLAVE RX mode before changing anything on the I2Cx_S register, but SDA still locks up on Low. Here is the piece of code at the very beginning of the IIC ISR:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14389519000262898 jive_macro_code jive_text_macro" data-renderedposition="92_8_1156_192" jivemacro_uid="_14389519000262898"&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;byte is;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;byte ic;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;is = I2C1_S;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;ic = I2C1_C1;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;if(is &amp;amp; 0x10) { // ARBL&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arbl = TRUE;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C1_C1 &amp;amp;= 0xCF; // Switch to RX SLAVE before cleaning ARBL (errata e6749)&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C1_S |= 0x10; // Clear ARBL&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;}&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;I2C1_S |= 0x02; // Clear IICIF&lt;/P&gt;&lt;/PRE&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;First, I save copies of I2C_C1 and I2C_S registers, and then I test for ARBL. If an arbitration loss has just occurred, I clear MST and TX bits on I2C_C1. Only after this, I clear the IICIF flag.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Unfortunately, it did not work. After receiving the slave ID, my boars puts SDA and SCL in Low, as it can be seen at my logic analyzer:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="screenshot1.png"&gt;&lt;IMG alt="screenshot1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/55454i9F4C09D3FAE0063C/image-size/large?v=v2&amp;amp;px=999" title="screenshot1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;After receiving the whole ID, both SDA and SCL go to low. My emulator board keeps transmitting the rest of the message, but it does not show up because of the lock. Channel 2 has a sync signal that is asserted right after my board starts transmitting. The other 4 channels have the bits of a state indicator that helps me running through the flowchart. According to it, after the code above it tests if the module is in MASTER mode (if(ic &amp;amp; 0x20)), and the answer is still yes, even after cleaning up MST bit. Then, it checks if it has received ACK, and the answer is yes. Finally, it supposedly send the next byte.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;It is funny that if the ID sent by the emulator does not match my board ID, my board releases the bus, even with the same tests going through (same program flow):&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="screenshot1.png"&gt;&lt;IMG alt="screenshot1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/55522i5C9B572C036C34D4/image-size/large?v=v2&amp;amp;px=999" title="screenshot1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Here my board releases the bus after the first data byte transfer (0x11). Notice the Sync signal that goes low after the transfer is complete or the cycle is aborted.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Any ideas?&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;STRONG&gt;EDITED:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;As I was using the copy of I2C_C1 to test Master mode (if(ic &amp;amp; 0x20)), the module was going through the Master mode branch of teh flowchart. I have corrected that, and now it follows the Slave mode branch, but the SDA and SCL lines still behave the same way.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;I have changed my code to work on polling mode, as the frequency is low (approx. 5kHz), and now I can go step by step through the ISR. I noticed that the SDA line goes low even before the first test (line 7 of my code sample above). After I execute line 9 (switch ro Slave RX), it also drives SCL line to Low. And all of this problem only happens when I have a Slave ID match.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:19:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422161#M24178</guid>
      <dc:creator>quevedo</dc:creator>
      <dc:date>2020-11-02T13:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: I2C SDA Lockup after arbitration loss</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422162#M24179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This problem was becoming a kind of obssession for me. After my last post, I kept testing, now breaking the flow inside my ISR and going step by step, and then I stumbled upon something very interesting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have added the code to transfer data from my emulator to my test board, using the board's slave ID, just like in the lock-up situation, but without waiting for the START signal from my test board. As I had a breakpoint at the very beginning of the ISR, and when I sent data with my test board's ID, the board halted at the beginning of the ISR... and SDA stayed Low!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Strangely, when I ran the code without breakpoints, it received nicely. I thought... every time the I2C module has a slave ID match, it puts SDA Low, which is obvious, since it has to ACK the ID. The problem is, if I do something that locks SCL Low, the 9th clock cycle will never occur, and SDA will not be released.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I had to figure what difference there was between receiving the ID with and without arbitration loss. Thus, I got back at my flowchart, and then it was clear: the code went through testing slave mode, then arbitration loss. Then, it tested for slave ID match, but both branches after this text &lt;STRONG&gt;were missing a dummy read to the Data Register!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After I added the dummy read, I ran the code again, and... surprise! Now I had my I2C transfer cycle working nicely!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Conclusion: slave ID matches force SDA to Low for the ACK bit. For some reason, when I switch to SLAVE RX, SCL also goes Low, and only after a dummy read at the Data Register both lines will be released!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps someone in the future.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Jorge for your feedback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Antonio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Aug 2015 17:19:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/I2C-SDA-Lockup-after-arbitration-loss/m-p/422162#M24179</guid>
      <dc:creator>quevedo</dc:creator>
      <dc:date>2015-08-07T17:19:37Z</dc:date>
    </item>
  </channel>
</rss>

