<?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>ColdFire/68K Microcontrollers and ProcessorsのトピックRe: I2C Help</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135935#M1726</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Trevor&lt;/P&gt;&lt;P&gt;I didn't check&amp;nbsp;your code (since I haven't actually used the IIC controller on the Coldfire yet)&amp;nbsp;but do have a suggestion&amp;nbsp;as to&amp;nbsp;what you could quickly check.&lt;/P&gt;&lt;P&gt;How have you defined the status registers (such as MCF_I2C_I2SR) which you are polling to see when each step has completed? Check that they are indeed defined as "volatile".&lt;/P&gt;&lt;P&gt;The CW will typically optimise the code (when volatile is not used) to read the location once and use&amp;nbsp;the same&amp;nbsp;value for subsequent 'polling'. It may then get stuck in a polling loop. Typically it is obvious that this is happening when a routine like that gets stuck when run at full speed&amp;nbsp;but it walks through with the debugger. as the flags are set fast enough at each step.&lt;/P&gt;&lt;P&gt;Maybe it's as simple as that? Otherwise I hope you can solve it - IIC is not that complicated if you are only doing single master transferes and is more convenient that SPI for multiple slaves - so weather it out - it will be worth it.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Mark Butcher&lt;BR /&gt;&lt;A href="http://www.mjbc.ch" rel="nofollow" target="_blank"&gt;www.mjbc.ch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 21 May 2006 17:17:44 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2006-05-21T17:17:44Z</dc:date>
    <item>
      <title>I2C Help</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135933#M1724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am starting my first experience with I2C! I am trying to communicate with a MAXIM keypad controller, and am using the following function to send an array of 4 bytes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void I2CsendString(uint8 *data, uint16 length, uint8 address, uint8 id)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint16 i;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2CR |= MCF_I2C_I2CR_MTX; //become master&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2CR |= MCF_I2C_I2CR_MSTA; //send start bit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2DR = id; //send slave addr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while( !(MCF_I2C_I2SR &amp;amp; MCF_I2C_I2SR_IIF )); //wait till xfer is done&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2SR &amp;amp;= ~MCF_I2C_I2SR_IIF; //clear flag&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2DR = address; //send register addr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while( !(MCF_I2C_I2SR &amp;amp; MCF_I2C_I2SR_IIF )); //wait till xfer is done&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2SR &amp;amp;= ~MCF_I2C_I2SR_IIF; //clear flag&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for(i = 0 ; i length ; i++)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2DR = data[i]; //send data byte addr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while( !(MCF_I2C_I2SR &amp;amp; MCF_I2C_I2SR_IIF )); //wait till xfer is done&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MCF_I2C_I2SR &amp;amp;= ~MCF_I2C_I2SR_IIF; //clear flag&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;now, for some reason, when this function gets called, it never returns! when i run the debugger, i see the stack having the function that called this one, then a memory offset from IPSBAR, which is to a set of memory that is cleared! it seems to get through the first few tranfers, at least (slave address, device register address), i think! can anyone see any holes in my code? By the way, the device wants to see a transfer like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[start][slave addr][ACK][control byte][ACK][N data bytes][ack after each byte][stop]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am running the bus at slower than 400kHz, which is the upper limit of the device, and am using the correct address, as per the datasheet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't have interrupts enabled for this, or anything like that (though there are other interrupts running on the device).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...SPI is so much easier!!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Trevor&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;--update--&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;i programmed the code to FLASH, and now it doesn't run off into space, but it doesn't look like the controller is getting initialized properly. can anyone see where an error might be?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you could look at the datasheet, maybe, that would be great (this is a MAX7348 device). you don't have to, but any suggestions on my code would be awesome too!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;/update&lt;/STRONG&gt;&lt;P&gt;Message Edited by airswit on &lt;SPAN class="date_text"&gt;05-13-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;01:00 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 May 2006 12:22:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135933#M1724</guid>
      <dc:creator>airswit</dc:creator>
      <dc:date>2006-05-13T12:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Help</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135934#M1725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Trevor,&lt;/P&gt;&lt;P&gt;Which ColdFire device?&lt;/P&gt;&lt;P&gt;I'm not an i2c expert (or even novice) but can point you to some example code for i2c that is on the Freescale web site along with appnotes:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.freescale.com/webapp/Download?colCode=MPC860COD12&amp;amp;appType=license&amp;amp;location=null&amp;amp;srch=1" rel="nofollow" target="_blank"&gt;https://www.freescale.com/webapp/Download?colCode=MPC860COD12&amp;amp;appType=license&amp;amp;location=null&amp;amp;srch=1&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/webapp/sps/site/overview.jsp?code=8BITAPPNOTEIIC&amp;amp;srch=1" rel="nofollow" target="_blank"&gt;http://www.freescale.com/webapp/sps/site/overview.jsp?code=8BITAPPNOTEIIC&amp;amp;srch=1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/webapp/TransformXMLServlet?XmlId=FAQ-3256&amp;amp;XslId=SingleFaqDisplay.xsl&amp;amp;XslId2=FAQAttachment.xsl&amp;amp;srch=1" rel="nofollow" target="_blank"&gt;http://www.freescale.com/webapp/TransformXMLServlet?XmlId=FAQ-3256&amp;amp;XslId=SingleFaqDisplay.xsl&amp;amp;XslId2=FAQAttachment.xsl&amp;amp;srch=1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards, DavidS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 May 2006 20:09:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135934#M1725</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2006-05-18T20:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Help</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135935#M1726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Trevor&lt;/P&gt;&lt;P&gt;I didn't check&amp;nbsp;your code (since I haven't actually used the IIC controller on the Coldfire yet)&amp;nbsp;but do have a suggestion&amp;nbsp;as to&amp;nbsp;what you could quickly check.&lt;/P&gt;&lt;P&gt;How have you defined the status registers (such as MCF_I2C_I2SR) which you are polling to see when each step has completed? Check that they are indeed defined as "volatile".&lt;/P&gt;&lt;P&gt;The CW will typically optimise the code (when volatile is not used) to read the location once and use&amp;nbsp;the same&amp;nbsp;value for subsequent 'polling'. It may then get stuck in a polling loop. Typically it is obvious that this is happening when a routine like that gets stuck when run at full speed&amp;nbsp;but it walks through with the debugger. as the flags are set fast enough at each step.&lt;/P&gt;&lt;P&gt;Maybe it's as simple as that? Otherwise I hope you can solve it - IIC is not that complicated if you are only doing single master transferes and is more convenient that SPI for multiple slaves - so weather it out - it will be worth it.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Mark Butcher&lt;BR /&gt;&lt;A href="http://www.mjbc.ch" rel="nofollow" target="_blank"&gt;www.mjbc.ch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 May 2006 17:17:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135935#M1726</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2006-05-21T17:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Help</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135936#M1727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Below are some sample calls to the attached driver.&amp;nbsp;The delays in the code are to make scope debugging easier.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;/* Enable the I2C signals */&lt;BR /&gt;&amp;nbsp;MCF_GPIO_PASPAR |= ( MCF_GPIO_PASPAR_SDA_SDA&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | MCF_GPIO_PASPAR_SCL_SCL);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;I2Cinit();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;printf(" initialization start!\n\n");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;I2CsendByte(0x10,0x10,slave_addr);&lt;BR /&gt;/* Wait for a bit */&lt;BR /&gt;i=50000;&lt;BR /&gt;while(i--);&lt;BR /&gt;&amp;nbsp;I2CsendByte(0x08,0x11,slave_addr);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;printf(" initialization complete!\n\n");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;for (i=0;i&amp;lt;8;i++)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;printf("data = 0x%02x\n",I2CreceiveByte(i,slave_addr));&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 May 2006 23:16:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135936#M1727</guid>
      <dc:creator>DrSeuss</dc:creator>
      <dc:date>2006-05-25T23:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Help</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135937#M1728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now,I use M52233 Demo Board + 24LC256.&lt;BR /&gt;I use Coldfire Lite for web server.&lt;BR /&gt;Can use this code for read/write 24LC256.?&lt;BR /&gt;I try many time.&lt;BR /&gt;It printf to terminal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;initialization start!&lt;BR /&gt;&amp;nbsp;initialization complete!&lt;BR /&gt;data = 0xFF&lt;/P&gt;&lt;P&gt;data = 0xFF&lt;/P&gt;&lt;P&gt;data = 0xFF&lt;/P&gt;&lt;P&gt;data = 0xFF&lt;/P&gt;&lt;P&gt;data = 0xFF&lt;/P&gt;&lt;P&gt;data = 0xFF&lt;/P&gt;&lt;P&gt;data = 0xFF&lt;/P&gt;&lt;P&gt;data = 0xFF&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jun 2010 19:18:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/I2C-Help/m-p/135937#M1728</guid>
      <dc:creator>TechCom</dc:creator>
      <dc:date>2010-06-17T19:18:42Z</dc:date>
    </item>
  </channel>
</rss>

