<?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: Kinetis SDK I2C driver BUSY bugs in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863728#M51645</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nicolas:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your feedback.&lt;/P&gt;&lt;P&gt;For your first issue, I will report it to the develop team.&lt;/P&gt;&lt;P&gt;For your second issue, could you please let me know how to reproduce it? it also happens&amp;nbsp; with a multi-master system?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Feb 2019 06:33:43 GMT</pubDate>
    <dc:creator>danielchen</dc:creator>
    <dc:date>2019-02-26T06:33:43Z</dc:date>
    <item>
      <title>Kinetis SDK I2C driver BUSY bugs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863727#M51644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On my system, I have two I2C masters : a Kinetis (K22FN512VLH12) and a smart battery.&lt;/P&gt;&lt;P&gt;I use MCUXpresso SDK V2.5.0.&lt;/P&gt;&lt;P&gt;I use the FreeRTOS I2C driver for the Kinetis to communicate with the smart battery.&lt;/P&gt;&lt;P&gt;I am facing 2 bugs where the I2C driver either returns BUSY infinitely or stalls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;First bug :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Here is the scenario :&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Application calls I2C_RTOS_Transfer()&lt;/LI&gt;&lt;LI&gt;I2C_RTOS_Transfer() calls I2C_MasterTransferNonBlocking()&lt;/LI&gt;&lt;LI&gt;I2C_MasterTransferNonBlocking() checks for handle-&amp;gt;state to be equal to kIdleState&lt;/LI&gt;&lt;LI&gt;I2C_MasterTransferNonBlocking() calls I2C_InitTransferStateMachine()&lt;/LI&gt;&lt;LI&gt;I2C_InitTransferStateMachine() modifies handle-&amp;gt;state&lt;/LI&gt;&lt;LI&gt;I2C_InitTransferStateMachine() calls I2C_MasterStart()&lt;/LI&gt;&lt;LI&gt;I2C_MasterStart() calls I2C_MasterGetStatusFlags()&lt;/LI&gt;&lt;LI&gt;I2C_MasterGetStatusFlags() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI&gt;I2C_MasterStart() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI&gt;I2C_InitTransferStateMachine() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI&gt;I2C_MasterTransferNonBlocking() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI&gt;I2C_RTOS_Transfer() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I2C_RTOS_Transfer() exits with a BUSY error but handle-&amp;gt;state is not reverted to kIdleState. So, next time the application calls I2C_RTOS_Transfer(), the process stops at step 3. This repeats infinitely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My solution to this problem is to revert handle-&amp;gt;state to kIdleState at the end of I2C_InitTransferStateMachine() function like this :&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; status_t &lt;SPAN class="token function"&gt;I2C_InitTransferStateMachine&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;I2C_Type &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;base&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; i2c_master_handle_t &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;handle&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; i2c_master_transfer_t &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;xfer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;//TODO&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    status_t result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; kStatus_Success&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    i2c_direction_t direction &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; xfer&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;direction&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;
    &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/* For normal transfer, send start. */&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;I2C_MasterStart&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;base&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;transfer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;slaveAddress&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; direction&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="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;result &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; kStatus_I2C_Busy&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// Added&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;state &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; kIdleState&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// Added&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

    &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;
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Second bug :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;There is a second bug which, sometimes, happens when the smart battery is plugged or unplugged.&lt;/P&gt;&lt;P&gt;In this scenario, I2C_RTOS_Transfer() never exits. It is stalled waiting for xSemaphoreTake() to return.&lt;/P&gt;&lt;P&gt;I suppose there is a race condition between a busy bus state or arbitration lost state and I2C driver sequencer.&lt;/P&gt;&lt;P&gt;I have not found a good fix for this bug.&lt;/P&gt;&lt;P&gt;My (temporary) solution is to specify a timeout to xSemaphoreTake().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nicolas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;EDIT :&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The first bug (BUSY) arises only with a multi-master system. In my case, the smart battery acts has a slave/master.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second bug is, I believe, much more complex to understand. However, it arises quite often when plugging-in/plugging-out the smart battery. Here, the problem is related to the SCL and SDA signals that are randomly driven in a high/low/undefined state. There might not be any other solution than managing the timeout. It might request a big amount of time to fix it. I don't have this time, so I'll keep my solution for now. Here it is :&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;status_t &lt;SPAN class="token function"&gt;I2C_RTOS_Transfer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i2c_rtos_handle_t &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;handle&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; i2c_master_transfer_t &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;transfer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    status_t status&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; err&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;             &lt;SPAN class="comment token"&gt;// Added&lt;/SPAN&gt;


    &lt;SPAN class="comment token"&gt;/* Lock resource mutex */&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;xSemaphoreTake&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;mutex&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; portMAX_DELAY&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; pdTRUE&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; kStatus_I2C_Busy&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

    status &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;I2C_MasterTransferNonBlocking&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;base&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;drv_handle&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; transfer&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;status &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; kStatus_Success&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="token function"&gt;xSemaphoreGive&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;mutex&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; status&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;/* Wait for transfer to finish */&lt;/SPAN&gt;
    err &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;xSemaphoreTake&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;semaphore&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;portTICK_PERIOD_MS&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// Modfied&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;err &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; pdTRUE&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;                                                &lt;SPAN class="comment token"&gt;// Added&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;//printf("!!! I2C_RTOS_Transfer timeout !!!\n");&lt;/SPAN&gt;
        handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;async_status &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; kStatus_I2C_Timeout&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                   &lt;SPAN class="comment token"&gt;// Added&lt;/SPAN&gt;
        &lt;SPAN class="token function"&gt;I2C_MasterTransferAbort&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;base&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;drv_handle&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;   &lt;SPAN class="comment token"&gt;// Added&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;/* Unlock resource mutex */&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;xSemaphoreGive&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;mutex&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;/* Return status captured by callback function */&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; handle&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;async_status&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2019 16:00:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863727#M51644</guid>
      <dc:creator>NicolasP</dc:creator>
      <dc:date>2019-01-25T16:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis SDK I2C driver BUSY bugs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863728#M51645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nicolas:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your feedback.&lt;/P&gt;&lt;P&gt;For your first issue, I will report it to the develop team.&lt;/P&gt;&lt;P&gt;For your second issue, could you please let me know how to reproduce it? it also happens&amp;nbsp; with a multi-master system?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2019 06:33:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863728#M51645</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2019-02-26T06:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis SDK I2C driver BUSY bugs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863729#M51646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your interest in my report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I said in my EDIT post, the second issue randomly happens when connecting/de-connecting the smart battery.&lt;/P&gt;&lt;P&gt;This is not a normal situation. I believe this happens only because the SDA and SCL lines are erroneously badly driven to an undefined state during the connection/de-connection of the battery.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Nicolas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2019 07:26:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863729#M51646</guid>
      <dc:creator>NicolasP</dc:creator>
      <dc:date>2019-02-26T07:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis SDK I2C driver BUSY bugs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863730#M51647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I will do some tests to verify this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2019 07:30:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863730#M51647</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2019-02-26T07:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis SDK I2C driver BUSY bugs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863731#M51648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this can be of any help, on my design I use the following hardware :&lt;/P&gt;&lt;P&gt;- &lt;A href="https://www.rrc-ps.com/en/accessories/battery-connectors/products/?tx_mindshapeproducts_detail%5Bproduct%5D=100&amp;amp;cHash=727b8587e312f251be91b0388d3dd770"&gt;RRC battery cable&lt;/A&gt;&lt;/P&gt;&lt;P&gt;- &lt;A href="https://www.rrc-ps.com/en/battery-packs/standard-battery-packs/products/rrc2054/"&gt;RRC battery&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nicolas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2019 07:41:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863731#M51648</guid>
      <dc:creator>NicolasP</dc:creator>
      <dc:date>2019-02-26T07:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis SDK I2C driver BUSY bugs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863732#M51649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/NicolasP"&gt;NicolasP&lt;/A&gt;‌, thank you for raising the issue.&lt;/P&gt;&lt;P&gt;I have some comments to your situation:&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Here is the scenario :&lt;/P&gt;&lt;OL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;Application calls I2C_RTOS_Transfer()&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_RTOS_Transfer() calls I2C_MasterTransferNonBlocking()&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_MasterTransferNonBlocking() checks for handle-&amp;gt;state to be equal to kIdleState&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_MasterTransferNonBlocking() calls I2C_InitTransferStateMachine()&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_InitTransferStateMachine() modifies handle-&amp;gt;state&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_InitTransferStateMachine() calls I2C_MasterStart()&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_MasterStart() calls I2C_MasterGetStatusFlags()&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_MasterGetStatusFlags() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_MasterStart() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_InitTransferStateMachine() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_MasterTransferNonBlocking() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;I2C_RTOS_Transfer() returns kStatus_I2C_Busy&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;May I know why the bus is busy? Is that because the bus is occupied by another master?&amp;nbsp; In the design thoughts of the low-level I2C driver, the I2C handle should be a global variable and multi-masters should&amp;nbsp;uses the same handle variable when call the I2C transfer APIs. So, it's definitely not allowed to revert the state variable to idle when&amp;nbsp;the call returns to busy state in&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I2C_MasterTransferNonBlocking()&lt;SPAN&gt;&amp;nbsp; API.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;I would suggest to call I2C_MasterTranferAbort API inside&amp;nbsp;I2C_RTOS_Transfer API when the call to&amp;nbsp;&lt;SPAN style="color: #3d3d3d;"&gt;I2C_MasterTransferNonBlocking does not return&amp;nbsp;kStatus_Success.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{code}&lt;/P&gt;&lt;P&gt;status_t I2C_RTOS_Transfer(i2c_rtos_handle_t *handle, i2c_master_transfer_t *transfer)&lt;BR /&gt;{&lt;BR /&gt; status_t status;&lt;/P&gt;&lt;P&gt;/* Lock resource mutex */&lt;BR /&gt; if (xSemaphoreTake(handle-&amp;gt;mutex, portMAX_DELAY) != pdTRUE)&lt;BR /&gt; {&lt;BR /&gt; return kStatus_I2C_Busy;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;status = I2C_MasterTransferNonBlocking(handle-&amp;gt;base, &amp;amp;handle-&amp;gt;drv_handle, transfer);&lt;BR /&gt; if (status != kStatus_Success)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;/* NEW !!! Add call to transfer abort to abort the transfer. */&lt;/P&gt;&lt;P&gt;I2C_MasterTransferAbort(&lt;SPAN&gt;(handle-&amp;gt;base, &amp;amp;handle-&amp;gt;drv_handle&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; xSemaphoreGive(handle-&amp;gt;mutex);&lt;BR /&gt; return status;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Wait for transfer to finish */&lt;BR /&gt; xSemaphoreTake(handle-&amp;gt;semaphore, portMAX_DELAY);&lt;/P&gt;&lt;P&gt;/* Unlock resource mutex */&lt;BR /&gt; xSemaphoreGive(handle-&amp;gt;mutex);&lt;/P&gt;&lt;P&gt;/* Return status captured by callback function */&lt;BR /&gt; return handle-&amp;gt;async_status;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;{code}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2019 08:27:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-SDK-I2C-driver-BUSY-bugs/m-p/863732#M51649</guid>
      <dc:creator>susansu</dc:creator>
      <dc:date>2019-03-11T08:27:20Z</dc:date>
    </item>
  </channel>
</rss>

