<?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>Kinetis Software Development Kit中的主题 How can I read variable length message w/ I2C?</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/How-can-I-read-variable-length-message-w-I2C/m-p/620489#M6466</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using a K22, which is acting as a slave, on a single master bus, and the K22 is the only slave device on the bus. &amp;nbsp;I'm using IAR EWARM w/ KSDK v1.3 and MQX. &amp;nbsp;I'm using the non-blocking I2C Send/Receive methods.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The requirement I have is that my K22 should be able to talk to 2 different devices, and should have knowledge of what device its talking to. &amp;nbsp;To do that, the first step is reading the system information from the devices and taking appropriate action based on which device was detected. &amp;nbsp;Here is the catch: ProductA's system information message is 5 bytes long, ProductB's system information message is 12 bytes long.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I do is, attempt to read 12 bytes and implement my own timeout of 2 seconds. &amp;nbsp;If I get 12 bytes back, great, we know its ProductB. &amp;nbsp;However, if the receive happens to timeout after 2 seconds, then I check to see if 5 bytes were read (7 bytes remaining left to be read), and if so, we know its ProductA.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's pseudocode to give a rough idea of what I'm doing:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;bool &lt;SPAN class="token function"&gt;ReadSysInfo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint8_t rxBuff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; uint32_t &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; numBytesRemaining&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; bool result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; true&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;I2C_Slave_SendData&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;txBuff&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//Send data to the master, who then parses this data and responds with the system status information&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; timeout &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OSA_TimeGetMsec&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; I2C_RX_TX_TIMEOUT&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;I2C_Slave_ReceiveData&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rxBuffer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;12&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//Receive 12 bytes&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;do&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentTime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OSA_TimeGetMsec&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;I2C_DRV_SlaveGetReceiveStatus&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;I2C_RTOS_SLAVE_INSTANCE&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; numBytesRemaining&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;status &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; kStatus_I2C_Success &lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt; timeout &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; currTimeMs&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;timeout &lt;SPAN class="operator token"&gt;&amp;lt;=&lt;/SPAN&gt; currTimeMs&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; false&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

uint8_t rxBuff&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;12&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
uint32_t nbr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//number of remaining bytes left to be read&lt;/SPAN&gt;
ProductType product&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
bool result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;ReadSysInfo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rxBuff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;nbr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; product &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ProductB&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;nbr &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//If we still have 7 bytes left to receive, then that means we read 5 bytes, which is the number of bytes ProductA will respond with&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; product &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ProductA&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is that, if I follow this method, and I'm talking to ProductA type, because I don't receive 12 bytes (and I only receive 5), the busy flag is held high and all following I2C communications fail because the I2C lines are pulled low. &amp;nbsp;If I change the call to read 5 bytes instead of 12, the busy bit is cleared after the STOP signal is received and everything works as expected.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is how should I properly handle this kind of issue? &amp;nbsp;Is there something in the SDK I can call that will force the I2C module to stop pulling the line low? &amp;nbsp;Any suggestion is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Feb 2017 03:43:02 GMT</pubDate>
    <dc:creator>kevinlfw</dc:creator>
    <dc:date>2017-02-10T03:43:02Z</dc:date>
    <item>
      <title>How can I read variable length message w/ I2C?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/How-can-I-read-variable-length-message-w-I2C/m-p/620489#M6466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using a K22, which is acting as a slave, on a single master bus, and the K22 is the only slave device on the bus. &amp;nbsp;I'm using IAR EWARM w/ KSDK v1.3 and MQX. &amp;nbsp;I'm using the non-blocking I2C Send/Receive methods.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The requirement I have is that my K22 should be able to talk to 2 different devices, and should have knowledge of what device its talking to. &amp;nbsp;To do that, the first step is reading the system information from the devices and taking appropriate action based on which device was detected. &amp;nbsp;Here is the catch: ProductA's system information message is 5 bytes long, ProductB's system information message is 12 bytes long.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I do is, attempt to read 12 bytes and implement my own timeout of 2 seconds. &amp;nbsp;If I get 12 bytes back, great, we know its ProductB. &amp;nbsp;However, if the receive happens to timeout after 2 seconds, then I check to see if 5 bytes were read (7 bytes remaining left to be read), and if so, we know its ProductA.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's pseudocode to give a rough idea of what I'm doing:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;bool &lt;SPAN class="token function"&gt;ReadSysInfo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint8_t rxBuff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; uint32_t &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; numBytesRemaining&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; bool result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; true&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;I2C_Slave_SendData&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;txBuff&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//Send data to the master, who then parses this data and responds with the system status information&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; timeout &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OSA_TimeGetMsec&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; I2C_RX_TX_TIMEOUT&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;I2C_Slave_ReceiveData&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rxBuffer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;12&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//Receive 12 bytes&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;do&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentTime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OSA_TimeGetMsec&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;I2C_DRV_SlaveGetReceiveStatus&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;I2C_RTOS_SLAVE_INSTANCE&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; numBytesRemaining&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;status &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; kStatus_I2C_Success &lt;SPAN class="operator token"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt; timeout &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; currTimeMs&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;timeout &lt;SPAN class="operator token"&gt;&amp;lt;=&lt;/SPAN&gt; currTimeMs&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; false&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

uint8_t rxBuff&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;12&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
uint32_t nbr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//number of remaining bytes left to be read&lt;/SPAN&gt;
ProductType product&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
bool result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;ReadSysInfo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rxBuff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;nbr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; product &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ProductB&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;nbr &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//If we still have 7 bytes left to receive, then that means we read 5 bytes, which is the number of bytes ProductA will respond with&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; product &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ProductA&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is that, if I follow this method, and I'm talking to ProductA type, because I don't receive 12 bytes (and I only receive 5), the busy flag is held high and all following I2C communications fail because the I2C lines are pulled low. &amp;nbsp;If I change the call to read 5 bytes instead of 12, the busy bit is cleared after the STOP signal is received and everything works as expected.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is how should I properly handle this kind of issue? &amp;nbsp;Is there something in the SDK I can call that will force the I2C module to stop pulling the line low? &amp;nbsp;Any suggestion is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2017 03:43:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/How-can-I-read-variable-length-message-w-I2C/m-p/620489#M6466</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2017-02-10T03:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I read variable length message w/ I2C?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/How-can-I-read-variable-length-message-w-I2C/m-p/620490#M6467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So far the best solution I've found is de-initializing the slave and then&amp;nbsp;&lt;SPAN&gt;initializing it again. &amp;nbsp;This seems kind of wonky, but I'll be more than happy to try other solutions.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2017 15:37:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/How-can-I-read-variable-length-message-w-I2C/m-p/620490#M6467</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2017-02-10T15:37:44Z</dc:date>
    </item>
  </channel>
</rss>

