<?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>S12 / MagniV MicrocontrollersのトピックRe: I2C Bus hangs after reset</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176065#M6172</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;void delay(){  int i;  for( i = 0 ; i &amp;lt; 5000 ; ++i)    asm {      nop ; nop ; nop ;nop    };}void I2CInit(void){  int i = 0;    PTCDD |= 3;  PTCPE |= 3;  PTCD   = 3;  for( i = 0 ; i &amp;lt; 30 ; ++i )    {      delay();      PTCD ^= 1;        }  PTCD |= 3;  PTCDD &amp;amp;= ~3; &lt;/PRE&gt;&lt;P&gt;I had this problem again, and had to to this to un-hang the external chip...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:24:54 GMT</pubDate>
    <dc:creator>JimDon</dc:creator>
    <dc:date>2020-10-29T09:24:54Z</dc:date>
    <item>
      <title>I2C Bus hangs after reset</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176064#M6171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;I wrote some code to interface to an I2C chip, and discovered that if reset, the I2C bus would hang about 50% of the time. (the code is in a tight loop reading the device).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It happens because the device I was talking to gets stuck the in the middle of a transfer, and drives SDA low. It's not really the modules fault.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This causes the I2C module to believe it has lost arbitration every time you try to start a transfer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(If the master drives a high, but sees a low, so it lost arbitration)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The solution is to set the port bits to output and drive them high before setting up the I2C port:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;void InitI2C(void){&amp;nbsp;&amp;nbsp; // This will unhang the I2C module if reset while sending&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DDRJ |= 0xc0;&amp;nbsp; // make the clock &amp;amp; data be output.&amp;nbsp;&amp;nbsp; PTJ&amp;nbsp; |= 0xc0;&amp;nbsp; // Drive them hi&amp;nbsp;&amp;nbsp; DDRJ &amp;amp;= ~0xC0; // Set them back to input.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IBCR = 0;&amp;nbsp;&amp;nbsp; IBCR |= IBCR_IBEN_MASK;&amp;nbsp;&amp;nbsp;&amp;nbsp; IBFD = 0x1f; // 100K at 24 MHz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IBAD = 0x7e;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by JimDon on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-01-02&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:20 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:24:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176064#M6171</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2020-10-29T09:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Bus hangs after reset</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176065#M6172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;void delay(){  int i;  for( i = 0 ; i &amp;lt; 5000 ; ++i)    asm {      nop ; nop ; nop ;nop    };}void I2CInit(void){  int i = 0;    PTCDD |= 3;  PTCPE |= 3;  PTCD   = 3;  for( i = 0 ; i &amp;lt; 30 ; ++i )    {      delay();      PTCD ^= 1;        }  PTCD |= 3;  PTCDD &amp;amp;= ~3; &lt;/PRE&gt;&lt;P&gt;I had this problem again, and had to to this to un-hang the external chip...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:24:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176065#M6172</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2020-10-29T09:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Bus hangs after reset</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176066#M6173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;In my opinion,&lt;/SPAN&gt; &lt;SPAN&gt;these files&lt;/SPAN&gt; &lt;SPAN&gt;are likely to&lt;/SPAN&gt; &lt;SPAN&gt;help you&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Feb 2011 09:01:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176066#M6173</guid>
      <dc:creator>Kr_Blue</dc:creator>
      <dc:date>2011-02-28T09:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Bus hangs after reset</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176067#M6174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had this problem years ago with a Coldfire.... what I did then was to generate SCL pulses until SDA became high (normally up to 8 bits is sufficient). Then generate a STOP condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Consider yourself lucky, because that Coldire I was working with that time didn't have a GPIO option on the I2C module's SCL/SDA pin and the I2C controller didn't support freeing the bus, so a HW mod (solder GPIOs to SCL SDA was required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Henko&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2011 04:16:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-Bus-hangs-after-reset/m-p/176067#M6174</guid>
      <dc:creator>Henko</dc:creator>
      <dc:date>2011-03-25T04:16:01Z</dc:date>
    </item>
  </channel>
</rss>

