<?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 Bug in LPSPI_MasterTransferBlocking() if bytesPerFrame &amp;lt; 4 in MCUXpresso SDK</title>
    <link>https://community.nxp.com/t5/MCUXpresso-SDK/Bug-in-LPSPI-MasterTransferBlocking-if-bytesPerFrame-lt-4/m-p/1093732#M2704</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #51626f; border: 0px;"&gt;There seems to be an&amp;nbsp;issue in LPSPI_MasterTransferBlocking() (as found in fsl_lpspi.c / SDK 2.7, MKE14F512VLL16). A related issue existed in SDK v2.6. (see &lt;A href="https://community.nxp.com/thread/525548"&gt;Bug in LPSPI_MasterTransferBlocking()?&lt;/A&gt;).&amp;nbsp;A fix was put in for SDK release 2.7 to address it, but I believe there is still a problem if bytesPerFrame is less than 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have observed is that if this&amp;nbsp;function&amp;nbsp;is preempted/interrupted for a substantial length of time at the wrong time, an overrun can still occur in&amp;nbsp;the Rx FIFO which causes the function to get stuck in an endless loop and&amp;nbsp;never return. I believe the problem is that the rxFifoMaxBytes value is initialize improperly for bytesPerFrame values less than 4.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This value&amp;nbsp;is currently set in SDK 2.7 as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;uint32_t rxFifoMaxBytes = 4U * fifoSize;&lt;/STRONG&gt;&lt;BR /&gt; &lt;BR /&gt;I believe it should instead&amp;nbsp;take bytesPerFrame into consideration. Something like:&lt;BR /&gt; &lt;BR /&gt;&lt;STRONG&gt;uint32_t rxFifoMaxBytes = ((bytesPerFrame &amp;lt;= 4U) ? bytesPerFrame : 4U) * fifoSize;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, I was using a bits per frame setting of 8 (so my bytesPerFrame is 1), and observed the same lockup as before. After putting in the proposed fix, the lockup no longer occurs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 May 2020 18:47:23 GMT</pubDate>
    <dc:creator>kevin_haake</dc:creator>
    <dc:date>2020-05-15T18:47:23Z</dc:date>
    <item>
      <title>Bug in LPSPI_MasterTransferBlocking() if bytesPerFrame &lt; 4</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Bug-in-LPSPI-MasterTransferBlocking-if-bytesPerFrame-lt-4/m-p/1093732#M2704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #51626f; border: 0px;"&gt;There seems to be an&amp;nbsp;issue in LPSPI_MasterTransferBlocking() (as found in fsl_lpspi.c / SDK 2.7, MKE14F512VLL16). A related issue existed in SDK v2.6. (see &lt;A href="https://community.nxp.com/thread/525548"&gt;Bug in LPSPI_MasterTransferBlocking()?&lt;/A&gt;).&amp;nbsp;A fix was put in for SDK release 2.7 to address it, but I believe there is still a problem if bytesPerFrame is less than 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have observed is that if this&amp;nbsp;function&amp;nbsp;is preempted/interrupted for a substantial length of time at the wrong time, an overrun can still occur in&amp;nbsp;the Rx FIFO which causes the function to get stuck in an endless loop and&amp;nbsp;never return. I believe the problem is that the rxFifoMaxBytes value is initialize improperly for bytesPerFrame values less than 4.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This value&amp;nbsp;is currently set in SDK 2.7 as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;uint32_t rxFifoMaxBytes = 4U * fifoSize;&lt;/STRONG&gt;&lt;BR /&gt; &lt;BR /&gt;I believe it should instead&amp;nbsp;take bytesPerFrame into consideration. Something like:&lt;BR /&gt; &lt;BR /&gt;&lt;STRONG&gt;uint32_t rxFifoMaxBytes = ((bytesPerFrame &amp;lt;= 4U) ? bytesPerFrame : 4U) * fifoSize;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, I was using a bits per frame setting of 8 (so my bytesPerFrame is 1), and observed the same lockup as before. After putting in the proposed fix, the lockup no longer occurs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2020 18:47:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Bug-in-LPSPI-MasterTransferBlocking-if-bytesPerFrame-lt-4/m-p/1093732#M2704</guid>
      <dc:creator>kevin_haake</dc:creator>
      <dc:date>2020-05-15T18:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in LPSPI_MasterTransferBlocking() if bytesPerFrame &lt; 4</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Bug-in-LPSPI-MasterTransferBlocking-if-bytesPerFrame-lt-4/m-p/1093733#M2705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kevin:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for sharing your feedback.&lt;/P&gt;&lt;P&gt;There is a bug fix for this issue in SDK 2.8.0_EVKB-IMXRT1050, which will be released later this month.&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>Wed, 17 Jun 2020 02:43:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Bug-in-LPSPI-MasterTransferBlocking-if-bytesPerFrame-lt-4/m-p/1093733#M2705</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2020-06-17T02:43:48Z</dc:date>
    </item>
  </channel>
</rss>

