<?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 QN9080 Missing Last SPI Byte in Wireless MCU</title>
    <link>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790186#M4957</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a QN9080 operating as a slave on a SPI bus controlled by an MK22 master device. The QN9080 is using SDK 2.2.0 and the MK22 is using SDK 2.3.1. The baud rate is 2 MHz. The&amp;nbsp;QN9080 is using the same techniques described&amp;nbsp;in the spi_polling_b2b_transfer_slave example that came with the SDK. The MK22 is using EDMA. Everything works fine if I am transferring less than 29 bytes.&amp;nbsp;However, the QN9080 never recognizes the transfer as completed if I transfer 29 bytes or more and the callback function passed into SPI_SlaveTransferCreateHandle never gets called. The result is that my while loop waiting for the slaveFinished flag never exits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I look at the handle passed into the&amp;nbsp;SPI_SlaveTransferNonBlocking function I can&amp;nbsp;why the callback never gets called. I can see that&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle.txRemainingBytes = 0&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle.txRemainingBytes = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle.toReceiveCnt = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After some trial and error, I found that I could&amp;nbsp;fix the issue by changing one parameter in the MK22 master controller. My master configuration originally had&amp;nbsp;lastSckToPcsDelayInNanoSec = 500. If I increase that to 1000, I can successfully transfer up to 47 bytes, but I see the same missing received byte on the slave side if I transfer 48 bytes or more. If I set&amp;nbsp;lastSckToPcsDelayInNanoSec = 2000, I can successfully transfer 255 bytes. I didn't go any higher than that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would prefer not to have 1.5 us added to&amp;nbsp;small byte count transfers just so I can support larger transfers. Is there anything I can do to reduce&amp;nbsp;lastSckToPcsDelayInNanoSec back down to its original value? the problem appears to be delays in the QN9080's fsl_spi, but I am not sure exactly where the issue is. If I cannot improve the performance, can the MK22 master&amp;nbsp;change&amp;nbsp;lastSckToPcsDelayInNanoSec before&amp;nbsp;each EDMA transfer, or does the entire initialization be performed again to change that value? If I can change&amp;nbsp;lastSckToPcsDelayInNanoSec before the transfer, I can&amp;nbsp;set it based on the number of bytes being transferred.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally, I am curious about why the&amp;nbsp;lastSckToPcsDelayInNanoSec value affects the number of bytes I can receive. It looks like the QN9080's fsl_spi is using pointers for data buffering, so the number of bytes should not affect access times for updating the buffers. Can you tell me why this is happening&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jun 2018 12:27:10 GMT</pubDate>
    <dc:creator>rickdickerson</dc:creator>
    <dc:date>2018-06-18T12:27:10Z</dc:date>
    <item>
      <title>QN9080 Missing Last SPI Byte</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790186#M4957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a QN9080 operating as a slave on a SPI bus controlled by an MK22 master device. The QN9080 is using SDK 2.2.0 and the MK22 is using SDK 2.3.1. The baud rate is 2 MHz. The&amp;nbsp;QN9080 is using the same techniques described&amp;nbsp;in the spi_polling_b2b_transfer_slave example that came with the SDK. The MK22 is using EDMA. Everything works fine if I am transferring less than 29 bytes.&amp;nbsp;However, the QN9080 never recognizes the transfer as completed if I transfer 29 bytes or more and the callback function passed into SPI_SlaveTransferCreateHandle never gets called. The result is that my while loop waiting for the slaveFinished flag never exits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I look at the handle passed into the&amp;nbsp;SPI_SlaveTransferNonBlocking function I can&amp;nbsp;why the callback never gets called. I can see that&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle.txRemainingBytes = 0&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle.txRemainingBytes = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle.toReceiveCnt = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After some trial and error, I found that I could&amp;nbsp;fix the issue by changing one parameter in the MK22 master controller. My master configuration originally had&amp;nbsp;lastSckToPcsDelayInNanoSec = 500. If I increase that to 1000, I can successfully transfer up to 47 bytes, but I see the same missing received byte on the slave side if I transfer 48 bytes or more. If I set&amp;nbsp;lastSckToPcsDelayInNanoSec = 2000, I can successfully transfer 255 bytes. I didn't go any higher than that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would prefer not to have 1.5 us added to&amp;nbsp;small byte count transfers just so I can support larger transfers. Is there anything I can do to reduce&amp;nbsp;lastSckToPcsDelayInNanoSec back down to its original value? the problem appears to be delays in the QN9080's fsl_spi, but I am not sure exactly where the issue is. If I cannot improve the performance, can the MK22 master&amp;nbsp;change&amp;nbsp;lastSckToPcsDelayInNanoSec before&amp;nbsp;each EDMA transfer, or does the entire initialization be performed again to change that value? If I can change&amp;nbsp;lastSckToPcsDelayInNanoSec before the transfer, I can&amp;nbsp;set it based on the number of bytes being transferred.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally, I am curious about why the&amp;nbsp;lastSckToPcsDelayInNanoSec value affects the number of bytes I can receive. It looks like the QN9080's fsl_spi is using pointers for data buffering, so the number of bytes should not affect access times for updating the buffers. Can you tell me why this is happening&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2018 12:27:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790186#M4957</guid>
      <dc:creator>rickdickerson</dc:creator>
      <dc:date>2018-06-18T12:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: QN9080 Missing Last SPI Byte</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790187#M4958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;was able to replicate this issue by running the QN9080&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;spi_polling_b2b_transfer_slave&lt;/SPAN&gt; example at 2Mhz. It works fine at 500kHz, so my assumption is that the SPI data is received faster than what it takes the&amp;nbsp;MCU to process the SPI interrupt and eventually loses data. I believe better performance could be achieved by enabling the SPI FIFOs, but let me run some tests on my side and I will give you an update on how to get it working at 2MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gerardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2018 02:28:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790187#M4958</guid>
      <dc:creator>gerardo_rodriguez</dc:creator>
      <dc:date>2018-06-21T02:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: QN9080 Missing Last SPI Byte</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790188#M4959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gerardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for confirming the problem. I am looking forward to seeing your solution.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Rick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2018 12:38:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790188#M4959</guid>
      <dc:creator>rickdickerson</dc:creator>
      <dc:date>2018-06-21T12:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: QN9080 Missing Last SPI Byte</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790189#M4960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gerardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently using&amp;nbsp;BOARD_BootClockHSRUN (AHB_clock.outFreq = 32 MHz) because the SPI is the only portion of the device I had been using thus far and that is what the SPI demo projects recommend. I am now ready to implement the BLE portion of my application but I see that all of the BLE demo applications for the QN9080 use&amp;nbsp;BOARD_BootClockRUN (&lt;SPAN&gt;AHB_clock.outFreq = 16 MHz)&lt;/SPAN&gt;. If I drop to a lower clock rate this problem may be exacerbated. Can I keep using&amp;nbsp;BOARD_BootClockHSRUN with my BLE application, or should I drop down to&amp;nbsp;BOARD_BootClockRUN and adjust&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;lastSckToPcsDelayInNanoSec&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;as needed with the slower clock?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Rick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2018 20:16:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790189#M4960</guid>
      <dc:creator>rickdickerson</dc:creator>
      <dc:date>2018-06-22T20:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: QN9080 Missing Last SPI Byte</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790190#M4961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made more tests and indeed the issue&amp;nbsp;at 2MHz baud rate only occurs when &lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;EM&gt;BOARD_BootClockRUN &lt;/EM&gt;is used and&amp;nbsp;&lt;/SPAN&gt;the AHB clock is 16MHz. When the&amp;nbsp;&lt;EM&gt;BOARD_BootClockHSRUN&amp;nbsp;&lt;/EM&gt;is used (32MHz AHB clock), there are no communication errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About the SPI FIFOs, it turns out the driver enables them by default and by changing its FIFO level trigger point made little effect when using 2MHz baud rate and 16MHz AHB clock. Another possible solution would be to use the DMA to offload processing power from the MCU and reach higher SPI speeds, but this would require some effort since currently there are no examples implementing this approach for the QN908x.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On BLE applications, you can use HSRUN without problems. In fact, if you enable the&amp;nbsp;&lt;EM&gt;gBleUseHSClock2MbpsPhy_c&amp;nbsp;&lt;/EM&gt;macro in&amp;nbsp;&lt;STRONG&gt;app_preinclude.h&lt;/STRONG&gt;, the HSRUN function will be used instead. See&amp;nbsp;&lt;STRONG&gt;board.c&lt;/STRONG&gt;:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="property macro token"&gt;#if gBleUseHSClock2MbpsPhy_c&lt;/SPAN&gt;
 &lt;SPAN class="token function"&gt;BOARD_BootClockHSRUN&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="property macro token"&gt;#else&lt;/SPAN&gt;
 &lt;SPAN class="token function"&gt;BOARD_InitBootClocks&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="property macro token"&gt;#endif&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gerardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2018 21:46:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/QN9080-Missing-Last-SPI-Byte/m-p/790190#M4961</guid>
      <dc:creator>gerardo_rodriguez</dc:creator>
      <dc:date>2018-06-25T21:46:25Z</dc:date>
    </item>
  </channel>
</rss>

