<?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>MCUXpresso SDKのトピックRe: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
    <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945652#M1713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response. I've been able to reduce the delay to only about 5 uS. I've also reduced the "Delay between transfers [ns]", found in MCUXpresso ConfigTools Peripherals/LPSPI1/General Configuration/Master Mode, to 100 ns for my initial configuration of the peripheral device at 10 MHz; subsequent communication takes place at 30 MHz with a 34 ns "Delay between transfers settings". (The "PCS to SCK delay time" and "Last SCK to PCS delay time" I've set to 5 ns and 0 ns, respectively).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wholeheartedly agree with you that a two-phase transfer, such as what I'm doing and which you mentioned, would be a nice addition to the LPSPI driver since, as you mentioned, this is a very common method of communicating with peripheral devices.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code for.reading my SPI device. The write operation is similar, except that the dummy address vyte is onot sent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bool FtdiChipHostMemRead ( uint32_t ftdiChipAddr, uint8_t *memAddr, uint32_t byteCount )&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;status_t lpspiStatus = kStatus_Fail;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;lpspi_transfer_t xfer;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;bool retval = false;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// FIX: remove the delay, if possible&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SDK_DelayAtLeastUs( 5 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( (byteCount &amp;lt;= FTDI_MAX_MEM_TXFR) &amp;amp;&amp;amp; ((ftdiChipAddr + byteCount) &amp;lt;= (FTDI_MAX_ADDR + 1)) )&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The masking off of the upper bits of the address, to indicate a host memory read to FTDI Chip,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// may be overkill, but since it's being masked anyway, why not?&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[0] = (ftdiChipAddr &amp;amp; 0x003f0000) &amp;gt;&amp;gt; 16;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[1] = (ftdiChipAddr &amp;amp; 0x0000ff00) &amp;gt;&amp;gt; 8;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[2] = (ftdiChipAddr &amp;amp; 0x000000ff);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[3] = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GPIO_PinWrite( BOARD_INITPINS_FT813_CSn_GPIO, BOARD_INITPINS_FT813_CSn_PIN, 0 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.txData = (uint8_t*) &amp;amp;ftdiXfer;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.rxData = NULL;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.dataSize = sizeof(ftdiXfer.hdr.addr);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Write out the address whence cometh the data&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( kStatus_Success == (lpspiStatus = LPSPI_MasterTransferBlocking( FT813_SPI_PERIPHERAL, &amp;amp;xfer )) )&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.txData = NULL;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.rxData= memAddr;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.dataSize = byteCount;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// FIX: remove the delay, if possible&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SDK_DelayAtLeastUs( 5 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The data being read is sent directly to the caller's read address&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( kStatus_Success == (lpspiStatus = LPSPI_MasterTransferBlocking( FT813_SPI_PERIPHERAL, &amp;amp;xfer )) )&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;retval = true;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GPIO_PinWrite( BOARD_INITPINS_FT813_CSn_GPIO, BOARD_INITPINS_FT813_CSn_PIN, 1 );&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO: remove for production. Debug only.&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if( false == retval ) __asm("BKPT");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return retval;&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Sep 2019 17:51:45 GMT</pubDate>
    <dc:creator>jeffthompson</dc:creator>
    <dc:date>2019-09-23T17:51:45Z</dc:date>
    <item>
      <title>LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945648#M1709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the MIMXRT1062 to talk to a device using SPI Master mode. I need to control the PCS line myself, as the device requires me to send it a 24-bit bit starting address for each data transfer, with PCS asserted continually during the address and data phase of each transfer. For simplicity, I've elected to use LPSPI_MasterTransferBlocking(). This technique worked quite well for me when I was using the K64F12 in a previous incarnation of the project.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Since this project needs to use the USB ports in Host CDC mode, I started with the host_cdc_bm example, added FreeRTOS, verified that worked, then added my SPI device code.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm working with the MIMRXT1060-EVK as a starting point, and using MCUXpresso 11 to configure LPSPI1 signals to go to the Arduino shield interface, where my SPI device attaches. I've supplied 0-ohm resistors for R278 – R281, to bring the signals I need to the Arduino shield.The LPSPI1 pins are set up with default values, except that I'm using GPIO1_IO24 as my software-controlled chip select.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Initially, the baud rate is set ro 10 MHz, but all the other peripheral settings are at their default values, as are the clocks. After I've successfully configured the SPI device, I'll increase the baud rate to 30 MHz. Again, this worked nicely for my K64F12 version.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've verified that LPSPI_MasterInit is called with the correct peripheral base address, config, and clock frequency, and that my chip select asserts and de-#asserts.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The problem is that my first few calls to LPSPI_MasterTransferBlocking, but then it returns kStatus_LPSPI_Busy, which I've never had happen before. What is the best way to handle this? The SDK API Reference Manual does not give any guidance on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2019 20:23:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945648#M1709</guid>
      <dc:creator>jeffthompson</dc:creator>
      <dc:date>2019-09-04T20:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945649#M1710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added a 1 tick delay—vTaskDelay(1)—between calls and no longer get the&amp;nbsp;kStatus_LPSPI_Busy status. But, why? I shouldn't have to pace my LPSPI accesses this way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2019 17:24:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945649#M1710</guid>
      <dc:creator>jeffthompson</dc:creator>
      <dc:date>2019-09-06T17:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945650#M1711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Will controlling the chip select in this way adversely affect LPSPI transfers to the SPI device?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2019 11:49:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945650#M1711</guid>
      <dc:creator>jeffthompson</dc:creator>
      <dc:date>2019-09-09T11:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945651#M1712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see NXP hasn't chimed in on this one yet.&amp;nbsp; I've had a look at the LPSPI driver, and the only way it returns&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;kStatus_LPSPI_Busy after a call to&amp;nbsp;&lt;SPAN&gt;LPSPI_MasterTransferBlocking() is if MBF (module busy) is set in SR (status register).&amp;nbsp; But looking at&amp;nbsp;LPSPI_MasterTransferBlocking(), it appears to ensure that the module won't be busy after a transfer; if rxData is provided, then it reads all expected data from the FIFO, or if rxData is null, it waits for the TCF (transfer complete) flag in SR to be set.&amp;nbsp; Per the datasheet, "In master mode when the LPSPI returns to idle state with the transmit FIFO empty, the Transfer&amp;nbsp;Complete Flag will set."&amp;nbsp; So if TCF is set, then the module is idle, and thus MBF should be clear.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;Can you post some code, i.e. how you're invoking the LPSPI SDK API?&amp;nbsp; It shouldn't matter that you're manually controlling the chip select; the LPSPI module doesn't care whether you route the PCS signal to the designated pin or not.&amp;nbsp; It should be valid to manually set your PCS low, call&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;LPSPI_MasterTransferBlocking(), and then set PCS high.&amp;nbsp; Also, what are you seeing on your scope when one of these transfer attempts returns busy?&amp;nbsp; Are your PCS and SCK signals somehow getting out of sync?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;(An aside: this is one thing I don't like about the FSL SPI API; there's no provision for doing a continuous transfer in pieces.&amp;nbsp; When accessing a memory device, it's common to send an address and then read/write data.&amp;nbsp; But their LPSPI driver assumes that the transfer will always be terminated at the conclusion.&amp;nbsp; And this aspect of their driver &lt;A _jive_internal="true" href="https://community.nxp.com/thread/500746"&gt;masks an erratum in their LPSPI peripheral&lt;/A&gt;.)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;David R.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2019 16:57:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945651#M1712</guid>
      <dc:creator>dmarks_ls</dc:creator>
      <dc:date>2019-09-23T16:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945652#M1713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response. I've been able to reduce the delay to only about 5 uS. I've also reduced the "Delay between transfers [ns]", found in MCUXpresso ConfigTools Peripherals/LPSPI1/General Configuration/Master Mode, to 100 ns for my initial configuration of the peripheral device at 10 MHz; subsequent communication takes place at 30 MHz with a 34 ns "Delay between transfers settings". (The "PCS to SCK delay time" and "Last SCK to PCS delay time" I've set to 5 ns and 0 ns, respectively).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wholeheartedly agree with you that a two-phase transfer, such as what I'm doing and which you mentioned, would be a nice addition to the LPSPI driver since, as you mentioned, this is a very common method of communicating with peripheral devices.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code for.reading my SPI device. The write operation is similar, except that the dummy address vyte is onot sent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bool FtdiChipHostMemRead ( uint32_t ftdiChipAddr, uint8_t *memAddr, uint32_t byteCount )&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;status_t lpspiStatus = kStatus_Fail;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;lpspi_transfer_t xfer;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;bool retval = false;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// FIX: remove the delay, if possible&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SDK_DelayAtLeastUs( 5 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( (byteCount &amp;lt;= FTDI_MAX_MEM_TXFR) &amp;amp;&amp;amp; ((ftdiChipAddr + byteCount) &amp;lt;= (FTDI_MAX_ADDR + 1)) )&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The masking off of the upper bits of the address, to indicate a host memory read to FTDI Chip,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// may be overkill, but since it's being masked anyway, why not?&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[0] = (ftdiChipAddr &amp;amp; 0x003f0000) &amp;gt;&amp;gt; 16;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[1] = (ftdiChipAddr &amp;amp; 0x0000ff00) &amp;gt;&amp;gt; 8;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[2] = (ftdiChipAddr &amp;amp; 0x000000ff);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftdiXfer.hdr.addr[3] = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GPIO_PinWrite( BOARD_INITPINS_FT813_CSn_GPIO, BOARD_INITPINS_FT813_CSn_PIN, 0 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.txData = (uint8_t*) &amp;amp;ftdiXfer;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.rxData = NULL;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.dataSize = sizeof(ftdiXfer.hdr.addr);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Write out the address whence cometh the data&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( kStatus_Success == (lpspiStatus = LPSPI_MasterTransferBlocking( FT813_SPI_PERIPHERAL, &amp;amp;xfer )) )&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.txData = NULL;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.rxData= memAddr;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.dataSize = byteCount;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// FIX: remove the delay, if possible&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SDK_DelayAtLeastUs( 5 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The data being read is sent directly to the caller's read address&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( kStatus_Success == (lpspiStatus = LPSPI_MasterTransferBlocking( FT813_SPI_PERIPHERAL, &amp;amp;xfer )) )&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;retval = true;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GPIO_PinWrite( BOARD_INITPINS_FT813_CSn_GPIO, BOARD_INITPINS_FT813_CSn_PIN, 1 );&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO: remove for production. Debug only.&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if( false == retval ) __asm("BKPT");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return retval;&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2019 17:51:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945652#M1713</guid>
      <dc:creator>jeffthompson</dc:creator>
      <dc:date>2019-09-23T17:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945653#M1714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmm.&amp;nbsp; I don't see anything obvious to suggest why you're getting&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;kStatus_LPSPI_Busy prior to starting a new transfer.&amp;nbsp; However, given what you're experiencing, and how you're controlling PCS, maybe try a couple of different things.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;1) Since you're manually controlling PCS, there's no need to set&amp;nbsp;kLPSPI_MasterPcsContinuous for your transfers.&amp;nbsp; Try turning that off.&amp;nbsp; Reason I suggest that, there's an &lt;A _jive_internal="true" href="https://community.nxp.com/thread/500746"&gt;erratum regarding LPSPI and continuous transfers&lt;/A&gt; that can affect read operations.&amp;nbsp; But the erratum doesn't apply if the CONT bit is 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;2) Just for giggles... set your transfer rate relatively low, say, 1 MHz, so that 1 clock time = 1 us.&amp;nbsp; Then play with the clock timing settings (LPSPI.CCR), and try maxing out CCR[SCKPCS]... that's the delay from the last clock edge to the rising edge of PCS.&amp;nbsp; In the NXP driver, that would be the&amp;nbsp;lastSckToPcsDelayInNanoSec setting.&amp;nbsp; The max is 255 cycles, which at 1 MHz would be 255 us, so maybe try 250000 ns.&amp;nbsp; Then see if your 5 us delay is still adequate.&amp;nbsp; This is checking whether the LPSPI peripheral perhaps is signaling "transfer complete" when it hasn't yet de-asserted PCS (internally, anyway).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, if you haven't already, put a scope on the SPI bus lines to make sure your driver is actually doing what you expect it to do.&amp;nbsp; If you don't have an analyzer pod, the &lt;A href="https://www.saleae.com/"&gt;Saleae Logic Pro 8&lt;/A&gt; is indispensable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Sorry I can't offer a genuine solution.&amp;nbsp; Maybe one of the NXP engineers can suggest something?&amp;nbsp; &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/Hui_Ma"&gt;Hui_Ma&lt;/A&gt;‌ ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;David R.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Oct 2019 18:57:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945653#M1714</guid>
      <dc:creator>dmarks_ls</dc:creator>
      <dc:date>2019-10-01T18:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945654#M1715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jeff:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please make a simple project to reproduce this issue with NXP evk board?&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>Mon, 28 Oct 2019 03:17:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/945654#M1715</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2019-10-28T03:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: LPSPI Peripheral Driver Polling Mode Returns Busy</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/1792394#M4579</link>
      <description>MIMXRT1024 LPSPI FRAM Reading&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I working on MIMXRT1024 to read and write the FRAM(MB85RS4MT). I am able to write the FRAM. After 1st data reading from FRAM, CS pin is not de-assert automatically after clearing TCR[CONT&amp;amp; CONTC &amp;amp; TX].&lt;BR /&gt;&lt;BR /&gt;when i reading FRAM, I writing 4 bytes data FRAM, and i waiting for data by setting LPSPI_TCR_TXMSK_MASK. i am able to read the data. but after reading, TCR[CONT&amp;amp; CONTC &amp;amp; TX] are cleared. But CS pin is not De-assert automatically.i attached my Reading code in here.&lt;BR /&gt;&lt;BR /&gt;status_t LPSPI_MasterTransferBlockingTXRX(LPSPI_Type *base, lpspi_transfer_t *transfer,uint8_t type){&lt;BR /&gt;&lt;BR /&gt;assert(transfer != NULL);&lt;BR /&gt;&lt;BR /&gt;/* Check that LPSPI is not busy.*/&lt;BR /&gt;if ((LPSPI_GetStatusFlags(base) &amp;amp; (uint32_t)kLPSPI_ModuleBusyFlag) != 0U)&lt;BR /&gt;{&lt;BR /&gt;return kStatus_LPSPI_Busy;&lt;BR /&gt;}&lt;BR /&gt;LPSPI_Enable(base, false);&lt;BR /&gt;/* Check arguements */&lt;BR /&gt;if (!LPSPI_CheckTransferArgument(base, transfer, false))&lt;BR /&gt;{&lt;BR /&gt;return kStatus_InvalidArgument;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;LPSPI_FlushFifo(base, true, true);&lt;BR /&gt;LPSPI_ClearStatusFlags(base, (uint32_t)kLPSPI_AllStatusFlag);&lt;BR /&gt;&lt;BR /&gt;/* Variables */&lt;BR /&gt;bool isTxMask = false;&lt;BR /&gt;bool isByteSwap = ((transfer-&amp;gt;configFlags &amp;amp; (uint32_t)kLPSPI_MasterByteSwap) != 0U);&lt;BR /&gt;uint8_t bytesEachWrite;&lt;BR /&gt;uint8_t bytesEachRead;&lt;BR /&gt;uint8_t *txData = transfer-&amp;gt;txData;&lt;BR /&gt;uint8_t *rxData = NULL;&lt;BR /&gt;uint8_t dummyData = g_lpspiDummyData[LPSPI_GetInstance(base)];&lt;BR /&gt;uint32_t readData = 0U;&lt;BR /&gt;uint32_t txRemainingByteCount = 4;&lt;BR /&gt;bool isPcsContinuous ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;uint32_t rxRemainingByteCount ;&lt;BR /&gt;uint32_t wordToSend =&lt;BR /&gt;((uint32_t)dummyData) | ((uint32_t)dummyData &amp;lt;&amp;lt; &lt;LI-EMOJI id="lia_smiling-face-with-sunglasses" title=":smiling_face_with_sunglasses:"&gt;&lt;/LI-EMOJI&gt; | ((uint32_t)dummyData &amp;lt;&amp;lt; 16) | ((uint32_t)dummyData &amp;lt;&amp;lt; 24);&lt;BR /&gt;/*The TX and RX FIFO sizes are always the same*/&lt;BR /&gt;uint32_t fifoSize = LPSPI_GetRxFifoSize(base);&lt;BR /&gt;uint32_t bytesPerFrame = ((base-&amp;gt;TCR &amp;amp; LPSPI_TCR_FRAMESZ_MASK) &amp;gt;&amp;gt; LPSPI_TCR_FRAMESZ_SHIFT) / 8U + 1U;&lt;BR /&gt;/* No need to configure PCS continous if the transfer byte count is smaller than frame size */&lt;BR /&gt;&lt;BR /&gt;uint32_t rxFifoMaxBytes = MIN(bytesPerFrame, 4U) * fifoSize;&lt;BR /&gt;uint32_t whichPcs = (transfer-&amp;gt;configFlags &amp;amp; LPSPI_MASTER_PCS_MASK) &amp;gt;&amp;gt; LPSPI_MASTER_PCS_SHIFT;&lt;BR /&gt;uint32_t temp = (base-&amp;gt;CFGR1 &amp;amp; LPSPI_CFGR1_PINCFG_MASK);&lt;BR /&gt;if(type==0){&lt;BR /&gt;txRemainingByteCount =4;// normal read and write&lt;BR /&gt;isPcsContinuous = true;&lt;BR /&gt;}&lt;BR /&gt;else{&lt;BR /&gt;txRemainingByteCount =1;&lt;BR /&gt;isPcsContinuous = (((transfer-&amp;gt;configFlags &amp;amp; (uint32_t)kLPSPI_MasterPcsContinuous) != 0U) &amp;amp;&amp;amp;&lt;BR /&gt;(bytesPerFrame &amp;lt; transfer-&amp;gt;dataSize));&lt;BR /&gt;}&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;uint32_t waitTimes;&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;/* Mask tx data in half duplex mode */&lt;BR /&gt;if (((temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdiInSdiOut)) || (temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdoInSdoOut))) &amp;amp;&amp;amp;&lt;BR /&gt;(txData == NULL))&lt;BR /&gt;{&lt;BR /&gt;isTxMask = true;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;base-&amp;gt;CFGR1 &amp;amp;= (~LPSPI_CFGR1_NOSTALL_MASK);&lt;BR /&gt;LPSPI_Enable(base, true);&lt;BR /&gt;&lt;BR /&gt;/* Configure transfer control register. */&lt;BR /&gt;base-&amp;gt;TCR = (base-&amp;gt;TCR &amp;amp; ~(LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK | LPSPI_TCR_RXMSK_MASK |&lt;BR /&gt;LPSPI_TCR_TXMSK_MASK | LPSPI_TCR_PCS_MASK)) |&lt;BR /&gt;LPSPI_TCR_PCS(whichPcs);&lt;BR /&gt;&lt;BR /&gt;/*TCR is also shared the FIFO, so wait for TCR written.*/&lt;BR /&gt;if (!LPSPI_TxFifoReady(base))&lt;BR /&gt;{&lt;BR /&gt;return kStatus_LPSPI_Timeout;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/* PCS should be configured separately from the other bits, otherwise it will not take effect. */&lt;BR /&gt;base-&amp;gt;TCR |= LPSPI_TCR_CONT(isPcsContinuous) | LPSPI_TCR_CONTC(isPcsContinuous)|&lt;BR /&gt;#ifdef SERIAL&lt;BR /&gt;LPSPI_TCR_WIDTH(0)&lt;BR /&gt;#else&lt;BR /&gt;LPSPI_TCR_WIDTH(1)&lt;BR /&gt;#endif&lt;BR /&gt;| LPSPI_TCR_RXMSK(NULL == rxData)/**/ ;&lt;BR /&gt;&lt;BR /&gt;/*TCR is also shared the FIFO, so wait for TCR written.*/&lt;BR /&gt;if (!LPSPI_TxFifoReady(base))&lt;BR /&gt;{&lt;BR /&gt;return kStatus_LPSPI_Timeout;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;if (bytesPerFrame &amp;lt;= 4U)&lt;BR /&gt;{&lt;BR /&gt;bytesEachWrite = (uint8_t)bytesPerFrame;&lt;BR /&gt;bytesEachRead = (uint8_t)bytesPerFrame;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;bytesEachWrite = 4U;&lt;BR /&gt;bytesEachRead = 4U;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/*Write the TX data until txRemainingByteCount is equal to 0 */&lt;BR /&gt;while (txRemainingByteCount &amp;gt; 0U)&lt;BR /&gt;{&lt;BR /&gt;if (txRemainingByteCount &amp;lt; bytesEachWrite)&lt;BR /&gt;{&lt;BR /&gt;bytesEachWrite = (uint8_t)txRemainingByteCount;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/*Wait until TX FIFO is not full*/&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;waitTimes = SPI_RETRY_TIMES;&lt;BR /&gt;while ((LPSPI_GetTxFifoCount(base) == fifoSize) &amp;amp;&amp;amp; (--waitTimes != 0U))&lt;BR /&gt;#else&lt;BR /&gt;while (LPSPI_GetTxFifoCount(base) == fifoSize)&lt;BR /&gt;#endif&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;if (waitTimes == 0U)&lt;BR /&gt;{&lt;BR /&gt;return kStatus_LPSPI_Timeout;&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;/* To prevent rxfifo overflow, ensure transmitting and receiving are executed in parallel */&lt;BR /&gt;if (((NULL == rxData) || (rxRemainingByteCount - txRemainingByteCount) &amp;lt; rxFifoMaxBytes))&lt;BR /&gt;{&lt;BR /&gt;if (isTxMask)&lt;BR /&gt;{&lt;BR /&gt;/* When TCR[TXMSK]=1, transfer is initiate by writting a new command word to TCR. TCR[TXMSK] is cleared&lt;BR /&gt;by hardware every time when TCR[FRAMESZ] bit of data is transfered.&lt;BR /&gt;In this case TCR[TXMSK] should be set to initiate each transfer. */&lt;BR /&gt;base-&amp;gt;TCR |= LPSPI_TCR_TXMSK_MASK;&lt;BR /&gt;if (isPcsContinuous &amp;amp;&amp;amp; (txRemainingByteCount == bytesPerFrame))&lt;BR /&gt;{&lt;BR /&gt;/* For the last piece of frame size of data, if is PCS continous mode(TCR[CONT]), TCR[CONTC] should&lt;BR /&gt;* be cleared to de-assert the PCS. Be sure to clear the TXMSK as well otherwise another FRAMESZ&lt;BR /&gt;* of data will be received. */&lt;BR /&gt;base-&amp;gt;TCR &amp;amp;= ~(LPSPI_TCR_CONTC_MASK | LPSPI_TCR_CONT_MASK | LPSPI_TCR_TXMSK_MASK);&lt;BR /&gt;}&lt;BR /&gt;txRemainingByteCount -= bytesPerFrame;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;if (txData != NULL)&lt;BR /&gt;{&lt;BR /&gt;wordToSend = LPSPI_CombineWriteData(txData, bytesEachWrite, isByteSwap);&lt;BR /&gt;txData += bytesEachWrite;&lt;BR /&gt;}&lt;BR /&gt;/* Otherwise push data to tx FIFO to initiate transfer */&lt;BR /&gt;//printf(" Read Send: %x",wordToSend);&lt;BR /&gt;LPSPI_WriteData(base, wordToSend);&lt;BR /&gt;txRemainingByteCount -= bytesEachWrite;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/* Check whether there is RX data in RX FIFO . Read out the RX data so that the RX FIFO would not overrun. */&lt;BR /&gt;if ((rxData != NULL) &amp;amp;&amp;amp; (rxRemainingByteCount != 0U))&lt;BR /&gt;{&lt;BR /&gt;/* To ensure parallel execution in 3-wire mode, after writting 1 to TXMSK to generate clock of&lt;BR /&gt;bytesPerFrame's data wait until bytesPerFrame's data is received. */&lt;BR /&gt;while (isTxMask &amp;amp;&amp;amp; (LPSPI_GetRxFifoCount(base) == 0U))&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;waitTimes = SPI_RETRY_TIMES;&lt;BR /&gt;while ((LPSPI_GetRxFifoCount(base) != 0U) &amp;amp;&amp;amp; (--waitTimes != 0U))&lt;BR /&gt;#else&lt;BR /&gt;while (LPSPI_GetRxFifoCount(base) != 0U)&lt;BR /&gt;#endif&lt;BR /&gt;{&lt;BR /&gt;readData = LPSPI_ReadData(base);&lt;BR /&gt;if (rxRemainingByteCount &amp;lt; bytesEachRead)&lt;BR /&gt;{&lt;BR /&gt;bytesEachRead = (uint8_t)rxRemainingByteCount;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;LPSPI_SeparateReadData(rxData, readData, bytesEachRead, isByteSwap);&lt;BR /&gt;rxData += bytesEachRead;&lt;BR /&gt;&lt;BR /&gt;rxRemainingByteCount -= bytesEachRead;&lt;BR /&gt;}&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;if (waitTimes == 0U)&lt;BR /&gt;{&lt;BR /&gt;return kStatus_LPSPI_Timeout;&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rxRemainingByteCount = transfer-&amp;gt;dataSize;&lt;BR /&gt;rxData = transfer-&amp;gt;rxData;&lt;BR /&gt;&lt;BR /&gt;//base-&amp;gt;TCR |= LPSPI_TCR_CONT(1) | LPSPI_TCR_CONTC(1) | LPSPI_TCR_TXMSK(1) | LPSPI_TCR_WIDTH(1);&lt;BR /&gt;base-&amp;gt;TCR = (base-&amp;gt;TCR &amp;amp; ~( LPSPI_TCR_RXMSK_MASK ));&lt;BR /&gt;base-&amp;gt;TCR |= LPSPI_TCR_CONT(1) | LPSPI_TCR_CONTC(1)|&lt;BR /&gt;#ifdef SERIAL&lt;BR /&gt;LPSPI_TCR_WIDTH(0)&lt;BR /&gt;#else&lt;BR /&gt;LPSPI_TCR_WIDTH(1)&lt;BR /&gt;#endif&lt;BR /&gt;|LPSPI_TCR_TXMSK(1)/**/ ;&lt;BR /&gt;&lt;BR /&gt;/* wait a little bit */&lt;BR /&gt;//int k=0;&lt;BR /&gt;//for (size_t i = 0; i &amp;lt; 1000000; i++);&lt;BR /&gt;/*TCR is also shared the FIFO, so wait for TCR written.*/&lt;BR /&gt;// if (!LPSPI_TxFifoReady(base))&lt;BR /&gt;// {&lt;BR /&gt;// return kStatus_LPSPI_Timeout;&lt;BR /&gt;// }&lt;BR /&gt;&lt;BR /&gt;/*Read out the RX data in FIFO*/&lt;BR /&gt;if (rxData != NULL)&lt;BR /&gt;{ waitTimes = SPI_RETRY_TIMES;&lt;BR /&gt;//printf("\n rxRemainingByteCount:");&lt;BR /&gt;while (rxRemainingByteCount &amp;gt; 0U)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;int b=0;&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;&lt;BR /&gt;while ((LPSPI_GetRxFifoCount(base) != 0U) &amp;amp;&amp;amp; (waitTimes != 0U))&lt;BR /&gt;#else&lt;BR /&gt;while (LPSPI_GetRxFifoCount(base) != 0U)&lt;BR /&gt;#endif&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;readData = LPSPI_ReadData(base);&lt;BR /&gt;if (rxRemainingByteCount &amp;lt; bytesEachRead)&lt;BR /&gt;{&lt;BR /&gt;bytesEachRead = (uint8_t)rxRemainingByteCount;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;LPSPI_SeparateReadData(rxData, readData, bytesEachRead, isByteSwap);&lt;BR /&gt;rxData += bytesEachRead;&lt;BR /&gt;&lt;BR /&gt;rxRemainingByteCount -= bytesEachRead;&lt;BR /&gt;// printf(" Rec : %X",readData);&lt;BR /&gt;if(rxRemainingByteCount==0){&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;waitTimes--;&lt;BR /&gt;if (waitTimes == 0U)&lt;BR /&gt;{&lt;BR /&gt;return kStatus_LPSPI_Timeout;&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;if (isPcsContinuous &amp;amp;&amp;amp; !isTxMask)&lt;BR /&gt;{&lt;BR /&gt;/* In PCS continous mode(TCR[CONT]), after write all the data in TX FIFO, TCR[CONTC] and TCR[CONT] should be&lt;BR /&gt;cleared to de-assert the PCS. Note that TCR register also use the TX FIFO. Also CONTC should be cleared when&lt;BR /&gt;tx is not masked, otherwise written to TCR register with TXMSK bit wet will initiate a new transfer. */&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;waitTimes = SPI_RETRY_TIMES;&lt;BR /&gt;while ((LPSPI_GetTxFifoCount(base) == fifoSize) &amp;amp;&amp;amp; (--waitTimes != 0U))&lt;BR /&gt;#else&lt;BR /&gt;while (LPSPI_GetTxFifoCount(base) == fifoSize)&lt;BR /&gt;#endif&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;#if SPI_RETRY_TIMES&lt;BR /&gt;if (waitTimes == 0U)&lt;BR /&gt;{&lt;BR /&gt;return kStatus_LPSPI_Timeout;&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;base-&amp;gt;TCR = (base-&amp;gt;TCR &amp;amp; ~(LPSPI_TCR_CONTC_MASK | LPSPI_TCR_CONT_MASK));&lt;BR /&gt;}&lt;BR /&gt;return kStatus_Success;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Can u help me solve this issue?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;yaseer msm.</description>
      <pubDate>Sat, 20 Jan 2024 09:58:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/LPSPI-Peripheral-Driver-Polling-Mode-Returns-Busy/m-p/1792394#M4579</guid>
      <dc:creator>Yaseer</dc:creator>
      <dc:date>2024-01-20T09:58:53Z</dc:date>
    </item>
  </channel>
</rss>

