<?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: Problem using I2C under MQX in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155951#M770</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You were correct that the I2C device address needed to be 7-bit (shifted 1-bit) then everything worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Aug 2011 04:38:56 GMT</pubDate>
    <dc:creator>MPotts</dc:creator>
    <dc:date>2011-08-10T04:38:56Z</dc:date>
    <item>
      <title>Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155944#M763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use I2C under MQX on an MCF52259 design. We have tested I2C under Processor Expert so know the hardware works. The I2C documentation and example are not very clear but I am doing the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To install/initialize I2C:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt; ﻿MCF52XX_I2C_INIT_STRUCT i2c0_init = {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BSP_I2C0_MODE,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BSP_I2C0_ADDRESS,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BSP_I2C0_BAUD_RATE,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BSP_I2C0_INT_LEVEL,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BSP_I2C0_INT_SUBLEVEL,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BSP_I2C0_TX_BUFFER_SIZE,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BSP_I2C0_RX_BUFFER_SIZE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = _mcf52xx_i2c_polled_install("i2c0:", &amp;amp;i2c0_init);&lt;/FONT&gt;&lt;BR /&gt;﻿﻿&lt;/P&gt;&lt;P&gt;This returns 0xA00 which I do not know whether is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To read an 8-byte buffer from I2C:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (NULL != (fd = fopen ("i2c0:", NULL))) goto fail;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; param = I2C_ADDR;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (I2C_OK != ioctl(fd, IO_IOCTL_I2C_SET_DESTINATION_ADDRESS, &amp;amp;param)) goto fail;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; param = sizeof(buff);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (I2C_OK != ioctl(fd, IO_IOCTL_I2C_SET_RX_REQUEST, &amp;amp;param)) goto fail;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fread(&amp;amp;buff, 1, sizeof(buff), fd);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (I2C_OK != ioctl(fd, IO_IOCTL_FLUSH_OUTPUT, &amp;amp;buff)) goto fail;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; fclose(fd);&lt;/FONT&gt;&lt;BR /&gt;﻿&lt;/P&gt;&lt;P&gt;This executes without indicating failure but reads incorrect data. If I change the destination I2C address it still reads the same data, so something is wrong!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 05:36:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155944#M763</guid>
      <dc:creator>MPotts</dc:creator>
      <dc:date>2011-08-03T05:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155945#M764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I mean&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if (NULL == (fd = fopen ("i2c0:", NULL))) goto fail;﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 06:49:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155945#M764</guid>
      <dc:creator>MPotts</dc:creator>
      <dc:date>2011-08-03T06:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155946#M765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;Mark,&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;I noticed you didn't include the STOP command.&amp;nbsp; In the MQX example code it goes immediately after the flush.&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&amp;nbsp;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_STOP, NULL);&lt;BR /&gt;﻿does that help?&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 16:32:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155946#M765</guid>
      <dc:creator>OldNick</dc:creator>
      <dc:date>2011-08-03T16:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155947#M766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added that but still get the same incorrect data. I am asking for 8 bytes but get back only 4 (0,0,0,1). The data appears after IO_IOCTL_FLUSH_OUTPUT﻿. The same data appears even if I change the I2C destination address!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 00:50:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155947#M766</guid>
      <dc:creator>MPotts</dc:creator>
      <dc:date>2011-08-04T00:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155948#M767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Try taking a look at the I2C example in some lab projects done for a seminar last year. Specifically you want to look at the &lt;A href="http://www.freescale.com/files/32bit/software/RPSS_Labs_for_CW10.zip%FEFF" rel="nofollow" target="_self"&gt;Sensor Web lab&lt;/A&gt; for the I2C code reading data from the TWR-Sensor board.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; You can also look at the &lt;A href="http://cache.freescale.com/files/32bit/doc/support_info/TWRK60N512QSDLAB.zip" rel="nofollow" target="_self"&gt;TWR-K60N512 Quick Start Demo&lt;/A&gt; for another example of using the MQX I2C driver to read accelerometer data. That project isn't set up for the MCF52259 that you're using, but the use of the I2C driver is the same. The pertinent code is in Accel_Task.c﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That should get you on the right track!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 05:29:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155948#M767</guid>
      <dc:creator>anthony_huereca</dc:creator>
      <dc:date>2011-08-04T05:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155949#M768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark,&lt;/P&gt;&lt;P&gt;lots of things that can go wrong.&lt;IMG alt=":robotsad:" class="emoticon emoticon-robotsad" id="robotsad" src="http://freescale.i.lithium.com/i/smilies/16x16_robot-sad.gif" title="Robot Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obvious things to check...&lt;/P&gt;&lt;P&gt;1. Is the&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;rc = _mcf52xx_i2c_polled_install("i2c0:", &amp;amp;i2c0_init);&lt;/FONT&gt;﻿&lt;/P&gt;&lt;P&gt;in the bsp or your code, or both? In my MQX build, you configure i2c device x as present (user_config.h) and the BSP loads it for you. (If you remember to rebuild it!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. All the "set" IO requests have a corresponding "get",&amp;nbsp; you could put those in just to check the setup of the driver.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. And finally, are you using 7-bit slave addressing?&lt;/P&gt;&lt;P&gt;porting old code, I had to define my slave devices as&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define I2C_SLAVE_ADDRESS&amp;nbsp;&amp;nbsp;&amp;nbsp; (0x88 &amp;gt;&amp;gt; 1) //i2c slave address in Kinetis is 7-bit!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which I only found out when I put a scope probe on the SDA and SCL lines.﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 15:30:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155949#M768</guid>
      <dc:creator>OldNick</dc:creator>
      <dc:date>2011-08-04T15:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155950#M769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You were right about &lt;FONT face="courier new,courier"&gt;_mcf52xx_i2c_polled_install("i2c0:", &amp;amp;i2c0_init)&lt;/FONT&gt; being called twice. I removed the redundant call but am still getting the same results. I will try the other checks you describe and see if I can resolve the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 07:07:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155950#M769</guid>
      <dc:creator>MPotts</dc:creator>
      <dc:date>2011-08-05T07:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using I2C under MQX</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155951#M770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You were correct that the I2C device address needed to be 7-bit (shifted 1-bit) then everything worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 04:38:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Problem-using-I2C-under-MQX/m-p/155951#M770</guid>
      <dc:creator>MPotts</dc:creator>
      <dc:date>2011-08-10T04:38:56Z</dc:date>
    </item>
  </channel>
</rss>

