<?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中的主题 Preventing buffer underrun at SPI slave</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Preventing-buffer-underrun-at-SPI-slave/m-p/1418227#M47982</link>
    <description>&lt;P&gt;Assuming I have the following code at the SPI master:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;           if (length &amp;amp;&amp;amp; (SSP0SR &amp;amp; TNF)) // Data to send and transmit FIFO isn’t full?
           {
                SSPODR = *sendBuffer++;
                length--;
           }&lt;/LI-CODE&gt;&lt;P&gt;where length is the number of SPI message to send.&amp;nbsp;&amp;nbsp; If I understand things right the lower layer SPI code will transmit as fast as it can.&lt;/P&gt;&lt;P&gt;If the slave reads the first message and cannot reply before the next message from the master arrives then buffer underrun can occur.&amp;nbsp;&amp;nbsp; How to change the above code to avoid this problem please?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 12:05:00 GMT</pubDate>
    <dc:creator>perdrix</dc:creator>
    <dc:date>2022-02-23T12:05:00Z</dc:date>
    <item>
      <title>Preventing buffer underrun at SPI slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Preventing-buffer-underrun-at-SPI-slave/m-p/1418227#M47982</link>
      <description>&lt;P&gt;Assuming I have the following code at the SPI master:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;           if (length &amp;amp;&amp;amp; (SSP0SR &amp;amp; TNF)) // Data to send and transmit FIFO isn’t full?
           {
                SSPODR = *sendBuffer++;
                length--;
           }&lt;/LI-CODE&gt;&lt;P&gt;where length is the number of SPI message to send.&amp;nbsp;&amp;nbsp; If I understand things right the lower layer SPI code will transmit as fast as it can.&lt;/P&gt;&lt;P&gt;If the slave reads the first message and cannot reply before the next message from the master arrives then buffer underrun can occur.&amp;nbsp;&amp;nbsp; How to change the above code to avoid this problem please?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 12:05:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Preventing-buffer-underrun-at-SPI-slave/m-p/1418227#M47982</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2022-02-23T12:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Preventing buffer underrun at SPI slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Preventing-buffer-underrun-at-SPI-slave/m-p/1418645#M47986</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have to say that there is NOT hand-shaking signal between SPI master and slave, it is possible that the master transfers data fast enough so that the spi slave has not enough time to read data from slave SPI receiver FIFO to memory, in the case, overflow event will happen, the received data maybe lost.&lt;/P&gt;
&lt;P&gt;So you can add a delay with such instruction as on the master side.&lt;/P&gt;
&lt;P&gt;__asm("nop");&lt;/P&gt;
&lt;P&gt;__asm("nop");&lt;/P&gt;
&lt;P&gt;__asm("nop");&lt;/P&gt;
&lt;P&gt;to delay the master transfer.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 01:22:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Preventing-buffer-underrun-at-SPI-slave/m-p/1418645#M47986</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2022-02-24T01:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Preventing buffer underrun at SPI slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Preventing-buffer-underrun-at-SPI-slave/m-p/1422584#M48102</link>
      <description>&lt;P&gt;If there are a number of messages in the Tx fifo, I cannot do that.&amp;nbsp; Yes I can delay after adding each message to the fifo so that there's only ever a maximum of one message in the fifo, but that seems less than ideal as it rather defeats the purpose of having a fifo in the first place.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 09:40:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Preventing-buffer-underrun-at-SPI-slave/m-p/1422584#M48102</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2022-03-03T09:40:15Z</dc:date>
    </item>
  </channel>
</rss>

