<?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>LPC MicrocontrollersのトピックI2C &amp; LPC1347 - Too many bytes are read when more than 1 byte is requested</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-LPC1347-Too-many-bytes-are-read-when-more-than-1-byte-is/m-p/525387#M8023</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mathseng on Wed Oct 09 19:31:43 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The sample code for LPC13xx (used for LPC1347) for the I2C example reads back too many bytes when bytes requested is 2 or greater.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The error occurs in the handling of state value 0x50.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Suggested solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My suggested correction is to compare the current updated read index plus 1 against the number of bytes being requested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is because the action to occur happens AFTER the NEXT byte read, thus showing the need to compare with the modified pointer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Implementation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Modify the comparison test code in i2c.c::void I2C_IRQHandler(void) as follows - this then causes the state machine to execute state 0x58 after the NEXT byte - state 0x58 handles the LAST byte being received.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case 0x50:/* Data byte has been received, regardless following ACK or NACK */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I2CSlaveBuffer[RdIndex++] = LPC_I2C-&amp;gt;DAT;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if ( (RdIndex +1) &amp;lt; I2CReadLength )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:56:45 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:56:45Z</dc:date>
    <item>
      <title>I2C &amp; LPC1347 - Too many bytes are read when more than 1 byte is requested</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-LPC1347-Too-many-bytes-are-read-when-more-than-1-byte-is/m-p/525387#M8023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mathseng on Wed Oct 09 19:31:43 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The sample code for LPC13xx (used for LPC1347) for the I2C example reads back too many bytes when bytes requested is 2 or greater.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The error occurs in the handling of state value 0x50.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Suggested solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My suggested correction is to compare the current updated read index plus 1 against the number of bytes being requested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is because the action to occur happens AFTER the NEXT byte read, thus showing the need to compare with the modified pointer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Implementation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Modify the comparison test code in i2c.c::void I2C_IRQHandler(void) as follows - this then causes the state machine to execute state 0x58 after the NEXT byte - state 0x58 handles the LAST byte being received.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case 0x50:/* Data byte has been received, regardless following ACK or NACK */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I2CSlaveBuffer[RdIndex++] = LPC_I2C-&amp;gt;DAT;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if ( (RdIndex +1) &amp;lt; I2CReadLength )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:56:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-LPC1347-Too-many-bytes-are-read-when-more-than-1-byte-is/m-p/525387#M8023</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:56:45Z</dc:date>
    </item>
  </channel>
</rss>

