<?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のトピックRe: I2C gets stuck</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1475358#M49208</link>
    <description>&lt;P&gt;I have used a scope to get more information:&lt;/P&gt;&lt;P&gt;If I insert a small delay between two consecutive calls to&amp;nbsp;SetupXferRecAndExecute it works fine!&lt;/P&gt;&lt;P&gt;See 1.png&lt;/P&gt;&lt;P class=""&gt;SetupXferRecAndExecute ( SC18IS602B_I2C_ADDRESS, sc18_LCDpage, 2, NULL, 0 );&lt;/P&gt;&lt;P class=""&gt;for ( int i=0 ; i&amp;lt;50 ; i++ );&lt;/P&gt;&lt;P class=""&gt;SetupXferRecAndExecute ( SC18IS602B_I2C_ADDRESS, sc18_LCDcol, 3, NULL, 0 );&lt;/P&gt;&lt;P class=""&gt;But if I omit that delay then the address byte of the second transfer is appended to the first transfer and it blocks&lt;/P&gt;&lt;P class=""&gt;See 2.png&lt;/P&gt;&lt;P class=""&gt;Any explanation/workaround for this? thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2022 14:26:16 GMT</pubDate>
    <dc:creator>EduardoGoncalves1966</dc:creator>
    <dc:date>2022-06-16T14:26:16Z</dc:date>
    <item>
      <title>I2C gets stuck</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1452412#M48636</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using this function that is provided with the I2C examples in&amp;nbsp;lpcopen_2_20_lpcxpresso_nxp_lpcxpresso_1549.zip&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;static void SetupXferRecAndExecute(uint8_t devAddr,&lt;BR /&gt;uint8_t *txBuffPtr,&lt;BR /&gt;uint16_t txSize,&lt;BR /&gt;uint8_t *rxBuffPtr,&lt;BR /&gt;uint16_t rxSize)&lt;BR /&gt;{&lt;BR /&gt;/* Setup I2C transfer record */&lt;BR /&gt;i2cmXferRec.slaveAddr = devAddr;&lt;BR /&gt;i2cmXferRec.status = 0;&lt;BR /&gt;i2cmXferRec.txSz = txSize;&lt;BR /&gt;i2cmXferRec.rxSz = rxSize;&lt;BR /&gt;i2cmXferRec.txBuff = txBuffPtr;&lt;BR /&gt;i2cmXferRec.rxBuff = rxBuffPtr;&lt;/P&gt;&lt;P&gt;Chip_I2CM_Xfer(LPC_I2C0, &amp;amp;i2cmXferRec);&lt;BR /&gt;/* Enable Master Interrupts */&lt;BR /&gt;Chip_I2C_EnableInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);&lt;/P&gt;&lt;P&gt;/* Wait for transfer completion */&lt;BR /&gt;while (i2cmXferRec.status == I2CM_STATUS_BUSY)&lt;BR /&gt;__WFI(); /* Sleep until next interrupt */&lt;/P&gt;&lt;P&gt;/* Clear all Interrupts */&lt;BR /&gt;Chip_I2C_ClearInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function seems to wait for the completion of the I2C transfer.&lt;/P&gt;&lt;P&gt;However if I call&amp;nbsp;SetupXferRecAndExecute twice, one after the other, it gets back with wrong values.&lt;/P&gt;&lt;P&gt;If I put a delay between the 2 calls all is fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SetupXferRecAndExecute ( PCA9535_I2C_ADDRESS, config_W, sizeof(config_W), NULL, 0 );&lt;/P&gt;&lt;P&gt;for ( int i=0 ; i&amp;lt;100 ; i++ );&amp;nbsp; // about 20us&lt;/P&gt;&lt;P&gt;SetupXferRecAndExecute ( PCA9535_I2C_ADDRESS, config_R, 1, &amp;amp;config_R[1], 2 );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes it also gets stuck on the second call generating an infinite amount interrupts that call I2C0_IRQHandler().&lt;/P&gt;&lt;P&gt;These interrupts keep calling&lt;/P&gt;&lt;P&gt;/* Master is Pending */&lt;BR /&gt;else if (status &amp;amp; I2C_STAT_MSTPENDING) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/* Branch based on Master State Code */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;switch (Chip_I2CM_GetMasterState(pI2C)) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Master idle */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case I2C_STAT_MSTCODE_IDLE:&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;&amp;lt;&amp;lt;---&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&amp;nbsp; &amp;nbsp; /* Do Nothing */&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;where status is&amp;nbsp;0x801.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like the transfer is considered as ended too soon... And when the second transfer is requested it gets stuck.&lt;/P&gt;&lt;P&gt;Is this known? Is there any update that solves this problem?&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 20:53:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1452412#M48636</guid>
      <dc:creator>EduardoGoncalves1966</dc:creator>
      <dc:date>2022-05-03T20:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: I2C gets stuck</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1456032#M48723</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;
&lt;P&gt;How about first check&amp;nbsp; Status of the current I2C transfer before call this function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 03:54:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1456032#M48723</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2022-05-11T03:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: I2C gets stuck</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1475357#M49207</link>
      <description>&lt;P&gt;&lt;BR /&gt;I have copied the while loop to check if the I2C is busy to the beginning of SetupXferRecAndExecute()&lt;/P&gt;&lt;P&gt;/* Wait for transfer completion */&lt;BR /&gt;while (i2cmXferRec.status == I2CM_STATUS_BUSY)&lt;BR /&gt;__WFI(); /* Sleep until next interrupt */&lt;/P&gt;&lt;P&gt;But still it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 14:21:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1475357#M49207</guid>
      <dc:creator>EduardoGoncalves1966</dc:creator>
      <dc:date>2022-06-16T14:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: I2C gets stuck</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1475358#M49208</link>
      <description>&lt;P&gt;I have used a scope to get more information:&lt;/P&gt;&lt;P&gt;If I insert a small delay between two consecutive calls to&amp;nbsp;SetupXferRecAndExecute it works fine!&lt;/P&gt;&lt;P&gt;See 1.png&lt;/P&gt;&lt;P class=""&gt;SetupXferRecAndExecute ( SC18IS602B_I2C_ADDRESS, sc18_LCDpage, 2, NULL, 0 );&lt;/P&gt;&lt;P class=""&gt;for ( int i=0 ; i&amp;lt;50 ; i++ );&lt;/P&gt;&lt;P class=""&gt;SetupXferRecAndExecute ( SC18IS602B_I2C_ADDRESS, sc18_LCDcol, 3, NULL, 0 );&lt;/P&gt;&lt;P class=""&gt;But if I omit that delay then the address byte of the second transfer is appended to the first transfer and it blocks&lt;/P&gt;&lt;P class=""&gt;See 2.png&lt;/P&gt;&lt;P class=""&gt;Any explanation/workaround for this? thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 14:26:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-gets-stuck/m-p/1475358#M49208</guid>
      <dc:creator>EduardoGoncalves1966</dc:creator>
      <dc:date>2022-06-16T14:26:16Z</dc:date>
    </item>
  </channel>
</rss>

