<?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 problem about I2C read sequence in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750055#M45656</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;when i used the demo code of I2C read function in thetext named "I2C_read_access _valu_ Transfer" ,the code cannot be run correctly,it alwals stoped in the code of while((!nakFlag) &amp;amp;&amp;amp; (!completionFlag)),therefor, I can write datas to the slave correct,so i am sure the slave address and the configuration of the I2C is correct.and now, I don't know how to solve the problem,and read datas from the slave address.&lt;BR /&gt;here is the demo code and the read sequence of my slave device:&lt;BR /&gt;demo code of I2C read function :&lt;BR /&gt;static bool I2C_ReadAccelRegs(I2C_Type *base, uint8_t device_addr, uint8_t reg_addr, uint8_t *rxBuff, uint32_t rxSize)&lt;BR /&gt;{&lt;BR /&gt;i2c_master_transfer_t masterXfer;&lt;BR /&gt;memset(&amp;amp;masterXfer, 0, sizeof(masterXfer));&lt;BR /&gt;masterXfer.slaveAddress = device_addr;&lt;BR /&gt;masterXfer.direction = kI2C_Read;&lt;BR /&gt;masterXfer.subaddress = reg_addr;&lt;BR /&gt;masterXfer.subaddressSize = 1;&lt;BR /&gt;masterXfer.data = rxBuff;&lt;BR /&gt;masterXfer.dataSize = rxSize;&lt;BR /&gt;masterXfer.flags = kI2C_TransferDefaultFlag;&lt;BR /&gt;/* direction=write : start+device_write;cmdbuff;xBuff; */&lt;BR /&gt;/* direction=recive : start+device_write;cmdbuff;repeatStart+device_read;xBuff; */&lt;BR /&gt;I2C_MasterTransferNonBlocking(BOARD_ACCEL_I2C_BASEADDR, &amp;amp;g_m_handle, &amp;amp;masterXfer);&lt;BR /&gt;/* wait for transfer completed. */&lt;BR /&gt;while ((!nakFlag) &amp;amp;&amp;amp; (!completionFlag))&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;nakFlag = false;&lt;BR /&gt;if (completionFlag == true)&lt;BR /&gt;{&lt;BR /&gt;completionFlag = false;&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;return false;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;the read sequence of my slave device:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="IMG_1048.JPG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/30545iF01B9A5138349B0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="IMG_1048.JPG" alt="IMG_1048.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Apr 2018 02:42:49 GMT</pubDate>
    <dc:creator>李珍珍</dc:creator>
    <dc:date>2018-04-20T02:42:49Z</dc:date>
    <item>
      <title>problem about I2C read sequence</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750055#M45656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;when i used the demo code of I2C read function in thetext named "I2C_read_access _valu_ Transfer" ,the code cannot be run correctly,it alwals stoped in the code of while((!nakFlag) &amp;amp;&amp;amp; (!completionFlag)),therefor, I can write datas to the slave correct,so i am sure the slave address and the configuration of the I2C is correct.and now, I don't know how to solve the problem,and read datas from the slave address.&lt;BR /&gt;here is the demo code and the read sequence of my slave device:&lt;BR /&gt;demo code of I2C read function :&lt;BR /&gt;static bool I2C_ReadAccelRegs(I2C_Type *base, uint8_t device_addr, uint8_t reg_addr, uint8_t *rxBuff, uint32_t rxSize)&lt;BR /&gt;{&lt;BR /&gt;i2c_master_transfer_t masterXfer;&lt;BR /&gt;memset(&amp;amp;masterXfer, 0, sizeof(masterXfer));&lt;BR /&gt;masterXfer.slaveAddress = device_addr;&lt;BR /&gt;masterXfer.direction = kI2C_Read;&lt;BR /&gt;masterXfer.subaddress = reg_addr;&lt;BR /&gt;masterXfer.subaddressSize = 1;&lt;BR /&gt;masterXfer.data = rxBuff;&lt;BR /&gt;masterXfer.dataSize = rxSize;&lt;BR /&gt;masterXfer.flags = kI2C_TransferDefaultFlag;&lt;BR /&gt;/* direction=write : start+device_write;cmdbuff;xBuff; */&lt;BR /&gt;/* direction=recive : start+device_write;cmdbuff;repeatStart+device_read;xBuff; */&lt;BR /&gt;I2C_MasterTransferNonBlocking(BOARD_ACCEL_I2C_BASEADDR, &amp;amp;g_m_handle, &amp;amp;masterXfer);&lt;BR /&gt;/* wait for transfer completed. */&lt;BR /&gt;while ((!nakFlag) &amp;amp;&amp;amp; (!completionFlag))&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;nakFlag = false;&lt;BR /&gt;if (completionFlag == true)&lt;BR /&gt;{&lt;BR /&gt;completionFlag = false;&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;return false;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;the read sequence of my slave device:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="IMG_1048.JPG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/30545iF01B9A5138349B0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="IMG_1048.JPG" alt="IMG_1048.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2018 02:42:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750055#M45656</guid>
      <dc:creator>李珍珍</dc:creator>
      <dc:date>2018-04-20T02:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: problem about I2C read sequence</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750056#M45657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;your code is exactly same as the demo. I think it should be ok if you send 1 to rxSize.&amp;nbsp;Do you have an oscilloscope to observe the waveform?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jing&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2018 09:39:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750056#M45657</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2018-04-20T09:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: problem about I2C read sequence</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750057#M45658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the trouble is i have no&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff; font-size: 14px;"&gt; oscilloscope now,so i don't know where the problem is.the problem confused me is i used the read function in the demo code,but it cannot work,so i just want to know,can the demo code work correctly,or if i need do some work when use the demo code?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; font-size: 14px;"&gt;thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2018 03:00:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750057#M45658</guid>
      <dc:creator>李珍珍</dc:creator>
      <dc:date>2018-04-24T03:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: problem about I2C read sequence</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750058#M45659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Yes of course, you can try the demo code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2018 09:17:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/problem-about-I2C-read-sequence/m-p/750058#M45659</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2018-04-24T09:17:56Z</dc:date>
    </item>
  </channel>
</rss>

