<?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>topic Re: I2c in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549833#M11142</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ToBeFrank on Thu Oct 06 12:21:30 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;For one thing, this code is not thread/interrupt safe, but that's likely not your problem. What are the values of STAT and CONSET after the line that clears SI?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:25:34 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:25:34Z</dc:date>
    <item>
      <title>I2c</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549832#M11141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by affonpign on Thu Oct 06 02:04:29 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello everybody, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use the Lib_MCU, which is a interface driver library Embedded Artists provides. I use the I2C driver. The I2C drivers can be found in the lpc17xx_i2c.c file. I copied the I2C_SendByte function right bellow:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/***********************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; * Function: I2C_SendByte&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; * Purpose: Send a byte&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; * Parameters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2Cx: Pointer to I2C register&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; * Returns: value of I2C status register after sending&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; **********************************************************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;static uint32_t I2C_SendByte (LPC_I2C_TypeDef *I2Cx, uint8_t databyte)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Make sure start bit is not active */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (I2Cx-&amp;gt;I2CONSET &amp;amp; I2C_I2CONSET_STA)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2Cx-&amp;gt;I2CONCLR = I2C_I2CONCLR_STAC;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2Cx-&amp;gt;I2DAT = databyte &amp;amp; I2C_I2DAT_BITMASK;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2Cx-&amp;gt;I2CONCLR = I2C_I2CONCLR_SIC;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!(I2Cx-&amp;gt;I2CONSET &amp;amp; I2C_I2CONSET_SI));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (I2Cx-&amp;gt;I2STAT &amp;amp; I2C_STAT_CODE_BITMASK);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following command should clear the interrupt flag:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I2Cx-&amp;gt;I2CONCLR = I2C_I2CONCLR_SIC;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But then the following line waits in the while loop until the interrupt flag SI is set. I do not understand that because we just cleared the interrupt flag. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I check the status of the control register I see that the interrupt flag is still set after it is cleared by the stated command. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone can explain that behavior?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lucas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:25:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549832#M11141</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: I2c</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549833#M11142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ToBeFrank on Thu Oct 06 12:21:30 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;For one thing, this code is not thread/interrupt safe, but that's likely not your problem. What are the values of STAT and CONSET after the line that clears SI?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:25:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549833#M11142</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: I2c</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549834#M11143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by affonpign on Thu Oct 06 23:47:22 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The important question is, why does the SI remains set after clearing. That makes no sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CONSET = 0x40&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;STAT = 0x18 or 0x28 depending if the slave address or a data byte was sent. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;affonpign&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:25:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549834#M11143</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: I2c</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549835#M11144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ToBeFrank on Fri Oct 07 07:57:33 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: affonpign&lt;/STRONG&gt;&lt;BR /&gt;The important question is, why does the SI remains set after clearing.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It doesn't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;CONSET = 0x40&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is correctly cleared.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your code then waits for it to be set again. After you send a byte, the slave should acknowledge it, which changes the I2C state and generates an interrupt. Are you sure you have the I2C initialized correctly and your hardware is ok?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:25:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549835#M11144</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: I2c</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549836#M11145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by affonpign on Wed Oct 12 02:22:42 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The code and the hardware work fine. I just did not understand the MCU library code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The SI is cleared but just after clearing it is set again because of the slave acknowledgement. I understand now, I was just surprised that it happen so fast.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;affonpign&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:25:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/I2c/m-p/549836#M11145</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:25:36Z</dc:date>
    </item>
  </channel>
</rss>

