<?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>S32KのトピックRe: s32k3 “Lpspi_Ip_SyncTransmit_FromIsr” Can this function use DMA transmission?</title>
    <link>https://community.nxp.com/t5/S32K/s32k3-Lpspi-Ip-SyncTransmit-FromIsr-Can-this-function-use-DMA/m-p/2322796#M56998</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi Petr, Thank you for your reply. &lt;/SPAN&gt;&lt;SPAN&gt;I have a follow-up question regarding SPI performance. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In our system, the MCU acts as SPI master, and a host (slave) asserts a GPIO interrupt pin to signal that a frame is ready. The MCU then initiates an SPI transfer in the interrupt callback, parses the data, and forwards it over CAN. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We currently use &lt;STRONG&gt;Lpspi_Ip_SyncTransmit&lt;/STRONG&gt;, which provides stable throughput across four CAN channels. However, when switching to DMA-based &lt;STRONG&gt;Lpspi_Ip_AsyncTransmit&lt;/STRONG&gt; to maximize speed, the transmission becomes highly unstable—channel rates fluctuate significantly.&lt;/SPAN&gt;&lt;SPAN&gt;And the overall speed also fails to reach the level of &lt;STRONG&gt;Lpspi_Ip_SyncTransmit&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a recommended approach to achieve stable, high-speed SPI transfers with &lt;STRONG&gt;Lpspi_Ip_AsyncTransmit&lt;/STRONG&gt; in this interrupt-driven master setup? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards, chen&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Feb 2026 02:05:07 GMT</pubDate>
    <dc:creator>chenxinyi</dc:creator>
    <dc:date>2026-02-26T02:05:07Z</dc:date>
    <item>
      <title>s32k3 “Lpspi_Ip_SyncTransmit_FromIsr” Can this function use DMA transmission?</title>
      <link>https://community.nxp.com/t5/S32K/s32k3-Lpspi-Ip-SyncTransmit-FromIsr-Can-this-function-use-DMA/m-p/2322178#M56977</link>
      <description>&lt;P&gt;The question, as stated in the title, is whether this function does not support DMA transmission? The original function code is pasted below.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Lpspi_Ip_StatusType Lpspi_Ip_SyncTransmit_FromIsr(const Lpspi_Ip_ExternalDeviceType *ExternalDevice,
                                          const uint8 *TxBuffer,
                                          uint8 *RxBuffer,
                                          uint16 Length,
                                          uint32 TimeOut)
{
    LPSPI_Type *Base;
    Lpspi_Ip_StateStructureType *State;
    uint8 NumberOfWrites, NumberOfReads;
    Lpspi_Ip_StatusType Status = LPSPI_IP_STATUS_SUCCESS;
    uint32 TimeoutTicks = OsIf_MicrosToTicks(TimeOut, LPSPI_IP_TIMEOUT_METHOD);
    uint32 CurrentTicks = 0u; /* initialize current counter */
    uint32 ElapsedTicks = 0u; /* elapsed will give timeout */
    uint8 Instance = 0u;

    UBaseType_t uxInterruptStatus;

    #if (LPSPI_IP_DEV_ERROR_DETECT == STD_ON)
    DevAssert(ExternalDevice != NULL_PTR);
    DevAssert(0u != Length);
    DevAssert(0u != TimeOut);
    Lpspi_Ip_CheckValidParameters(ExternalDevice, Length);
    #endif
    Instance = ExternalDevice-&amp;gt;Instance;
    State = Lpspi_Ip_apxStateStructureArray[Instance];
    #if (LPSPI_IP_DEV_ERROR_DETECT == STD_ON)
    DevAssert(State != NULL_PTR);
    #endif

    Base = Lpspi_Ip_apxBases[Instance];
    // SchM_Enter_Spi_SPI_EXCLUSIVE_AREA_08();
    uxInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
    if (LPSPI_IP_BUSY == State-&amp;gt;Status)
    {
        // SchM_Exit_Spi_SPI_EXCLUSIVE_AREA_08();
        taskEXIT_CRITICAL_FROM_ISR(uxInterruptStatus);
        Status = LPSPI_IP_STATUS_FAIL;
    }
    else
    {
        /* Mark the hardware as busy. */
        State-&amp;gt;Status = LPSPI_IP_BUSY;
        State-&amp;gt;ExternalDevice = ExternalDevice;
        // SchM_Exit_Spi_SPI_EXCLUSIVE_AREA_08();
        taskEXIT_CRITICAL_FROM_ISR(uxInterruptStatus);

        /* Disable DMA requests and all interrupts */
        Base-&amp;gt;DER = 0u;
        Base-&amp;gt;IER = 0u;
        Base-&amp;gt;CFGR0 = State-&amp;gt;ExternalDevice-&amp;gt;Cfgr0;

        /* Reset current FIFO slots are available to fill at beginning of job (HLD).*/
        State-&amp;gt;CurrentTxFifoSlot = LPSPI_IP_FIFO_SIZE_U8;
        Lpspi_TransmitTxInit_FromIsr(Instance, (const uint8 *)TxBuffer, Length);
        Lpspi_TransmitRxInit(Instance, RxBuffer, Length);

        CurrentTicks = OsIf_GetCounter(LPSPI_IP_TIMEOUT_METHOD); /* initialize current counter */
        while (State-&amp;gt;RxIndex != State-&amp;gt;ExpectedFifoReads)
        {
            /* RECEIVE DATA */
            /* Read all Data available in receive HW fifo. */
            NumberOfReads = (uint8)(((Base-&amp;gt;FSR) &amp;amp; LPSPI_FSR_RXCOUNT_MASK) &amp;gt;&amp;gt; LPSPI_FSR_RXCOUNT_SHIFT);
            if (NumberOfReads != 0u)
            {
                /* Limits to remaining frames. */
                if (NumberOfReads &amp;gt; (State-&amp;gt;ExpectedFifoReads - State-&amp;gt;RxIndex))
                {
                    NumberOfReads = (uint8)(State-&amp;gt;ExpectedFifoReads - State-&amp;gt;RxIndex);
                }
                /* If these are the first frames of this channel. Current TXFIFO slot must be plus 1 because the slot of CMD have moved out */
                if (0u == State-&amp;gt;RxIndex)
                {
                    State-&amp;gt;CurrentTxFifoSlot += 1u;
                }
                /* Read Data from RX FIFO */
                Lpspi_Ip_ReadDataFromFifo(Instance, NumberOfReads);
                /* Update current FIFO slots are available to fill .*/
                State-&amp;gt;CurrentTxFifoSlot += NumberOfReads;
                ElapsedTicks = 0u;
            }

            /* TRANSMIT DATA */
            /* Push Data until HW fifo is full or transfer is done. */
            /* After driver code read all frames in RX FIFO, if there are still some frames in TX FIFO, at the time before driver code check number of frames available in TX FIFO
            to prepare to fill TX FIFO. At that time, interrupt occurred, and the time to process interrupt is longer than the time to transfer all frames in TX FIFO.
            So TX FIFO will be empty and some frames received in RX FIFO, then the program is returned from interrupt and fill TX FIFO until full.
            And there is a interrupt occurred after that before read all frames in RX FIFO, and the time to process interrupt is longer than the time to transfer all frames in TX FIFO.
            State-&amp;gt;CurrentTxFifoSlot variable is used to hanlde number of frames are "on bus transfer". They are always less than FIFO size */
            if ((State-&amp;gt;CurrentTxFifoSlot != 0u))
            {
                if (State-&amp;gt;ExpectedFifoWrites != State-&amp;gt;TxIndex)
                {
                    NumberOfWrites = State-&amp;gt;CurrentTxFifoSlot;
                    /* Limits to remaining frames. */
                    if (NumberOfWrites &amp;gt; (State-&amp;gt;ExpectedFifoWrites - State-&amp;gt;TxIndex))
                    {
                        NumberOfWrites = (uint8)(State-&amp;gt;ExpectedFifoWrites - State-&amp;gt;TxIndex);
                    }
                    /* Push Data into TX FIFO */
                    Lpspi_Ip_PushDataToFifo(Instance, NumberOfWrites);
                    State-&amp;gt;CurrentTxFifoSlot -= NumberOfWrites;
                    ElapsedTicks = 0u;
                }
                else
                {
                    if ((FALSE == State-&amp;gt;KeepCs) &amp;amp;&amp;amp; (0u != (Base-&amp;gt;TCR &amp;amp; LPSPI_TCR_CONT_MASK)))
                    {
                        /* Clear CS */
                        Base-&amp;gt;TCR &amp;amp;= ~(LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK);
                    }
                }
            }
            ElapsedTicks += OsIf_GetElapsed(&amp;amp;CurrentTicks, LPSPI_IP_TIMEOUT_METHOD);
            if (ElapsedTicks &amp;gt;= TimeoutTicks)
            {
                Status = LPSPI_IP_TIMEOUT;
                break;
            }
        }
        if ((LPSPI_IP_STATUS_SUCCESS != Status) || (0u == Length))
        {
#if (STD_OFF == LPSPI_IP_DEV_ERROR_DETECT)
            /* Return Fail status if length is 0. Error Detect is enabled, nothing need to be done here */
            if (0u == Length)
            {
                Status = LPSPI_IP_STATUS_FAIL;
            }
#endif
            State-&amp;gt;Status = LPSPI_IP_FAULT;
        }
        else
        {
            State-&amp;gt;Status = LPSPI_IP_IDLE;
        }
    }
    return Status;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 25 Feb 2026 02:29:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/s32k3-Lpspi-Ip-SyncTransmit-FromIsr-Can-this-function-use-DMA/m-p/2322178#M56977</guid>
      <dc:creator>chenxinyi</dc:creator>
      <dc:date>2026-02-25T02:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: s32k3 “Lpspi_Ip_SyncTransmit_FromIsr” Can this function use DMA transmission?</title>
      <link>https://community.nxp.com/t5/S32K/s32k3-Lpspi-Ip-SyncTransmit-FromIsr-Can-this-function-use-DMA/m-p/2322486#M56988</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;not sure of teh RTD version you are using, but seems&amp;nbsp;Lpspi_Ip_SyncTransmit_FromIsr() is not in RTD.&lt;BR /&gt;The code&amp;nbsp;cannot use DMA because the code explicitly disables it.&lt;BR /&gt;If you want DMA → use Lpspi_Ip_AsyncTransmit() with DMA enabled in SpiPhyUnit / RM / DMAMUX.&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 10:54:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/s32k3-Lpspi-Ip-SyncTransmit-FromIsr-Can-this-function-use-DMA/m-p/2322486#M56988</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2026-02-25T10:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: s32k3 “Lpspi_Ip_SyncTransmit_FromIsr” Can this function use DMA transmission?</title>
      <link>https://community.nxp.com/t5/S32K/s32k3-Lpspi-Ip-SyncTransmit-FromIsr-Can-this-function-use-DMA/m-p/2322796#M56998</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Petr, Thank you for your reply. &lt;/SPAN&gt;&lt;SPAN&gt;I have a follow-up question regarding SPI performance. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In our system, the MCU acts as SPI master, and a host (slave) asserts a GPIO interrupt pin to signal that a frame is ready. The MCU then initiates an SPI transfer in the interrupt callback, parses the data, and forwards it over CAN. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We currently use &lt;STRONG&gt;Lpspi_Ip_SyncTransmit&lt;/STRONG&gt;, which provides stable throughput across four CAN channels. However, when switching to DMA-based &lt;STRONG&gt;Lpspi_Ip_AsyncTransmit&lt;/STRONG&gt; to maximize speed, the transmission becomes highly unstable—channel rates fluctuate significantly.&lt;/SPAN&gt;&lt;SPAN&gt;And the overall speed also fails to reach the level of &lt;STRONG&gt;Lpspi_Ip_SyncTransmit&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a recommended approach to achieve stable, high-speed SPI transfers with &lt;STRONG&gt;Lpspi_Ip_AsyncTransmit&lt;/STRONG&gt; in this interrupt-driven master setup? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards, chen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 02:05:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/s32k3-Lpspi-Ip-SyncTransmit-FromIsr-Can-this-function-use-DMA/m-p/2322796#M56998</guid>
      <dc:creator>chenxinyi</dc:creator>
      <dc:date>2026-02-26T02:05:07Z</dc:date>
    </item>
  </channel>
</rss>

