S32K144W SPI SCLK ,delay after four bytes

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K144W SPI SCLK ,delay after four bytes

Jump to solution
1,859 Views
tyty697
Contributor II

This is my SPI1 config屏幕截图 2025-09-24 184848.png屏幕截图 2025-09-24 184848.png

I will transfer 40 bytes

LPSPI_DRV_MasterTransferBlocking(INST_LPSPI_1, config_arr, rx_buff, 40, OSIF_WAIT_FOREVER);

This is wave of SCLK.I wish SCLK is contious.TDR and RDR is 32 bits,does it have anything to do with it?What can I do to slove this problem?

9749e2626aec43a7b43e1a9b7a968e8a.png9749e2626aec43a7b43e1a9b7a968e8a.png

Tags (2)
0 Kudos
Reply
1 Solution
1,768 Views
PavelL
NXP Employee
NXP Employee

Hello @tyty697 ,

Just a general hint: 

You may try switch to the non-blocking DMA API (LPSPI_DRV_MasterTransfer) and chaining the transfers without CPU intervention. This allows for near-continuous SPI communication and better timing control.

Best regards,

Pavel

View solution in original post

0 Kudos
Reply
5 Replies
1,835 Views
PavelL
NXP Employee
NXP Employee

Hello @tyty697 ,

Thank you for sharing the configuration and waveform details.

Based on your setup, the observed delay in SCLK after every 4 bytes is likely caused by the PCS continuous setting being disabled. When this option is unchecked, the chip select (PCS) signal is deasserted between frames, which introduces gaps in the SCLK waveform.

To achieve a continuous SCLK during the entire 40-byte transfer, we recommend enabling the PCS continuous option in your LPSPI master configuration. This will keep PCS asserted throughout the transfer and eliminate the inter-frame delays.

If your SPI slave supports wider frame sizes, you may increase the Bits/frame setting (e.g., to 16 or 32) to reduce the number of frames and potentially eliminate the gaps in SCLK caused by PCS toggling or FIFO refill latency.

Additionally, consider using DMA-based transfer instead of the blocking interrupt-based API. DMA can help maintain a smoother data flow and reduce latency between FIFO refills.

For future measurements, we kindly ask you to also include the PCS signal in the waveform capture. This will help us better understand the timing behavior and interactions between PCS and SCLK.

Best regards,

Pavel

0 Kudos
Reply
1,819 Views
tyty697
Contributor II

Now I clicked pcs contious,this is spi config

屏幕截图 2025-09-25 090321.png屏幕截图 2025-09-25 090321.png

Set PCSSCLK and sclkpcs 1,1

LPSPI_DRV_MasterSetDelay(INST_LPSPI_1, 1, 1, 1);

PCS and sclk waveform shows here

 1d05c04a3f364e20b74d4babbc6c6396.png1d05c04a3f364e20b74d4babbc6c6396.png9924e180-8b6c-4417-9cff-3158b9148dee.png9924e180-8b6c-4417-9cff-3158b9148dee.png

Delay after four bytes too. I see this function used in the spi IRQHandler when TX Data Flag

/*!
 * @brief Fill up the TX FIFO with data.
 * This function fills up the TX FIFO with data based on the bytes/frame.
 * This is not a public API as it is called from other driver functions.
 */
void LPSPI_DRV_FillupTxBuffer(uint32_t instance)
{
    /* Instantiate local variable of type dspi_master_state_t and point to global state. */
    lpspi_state_t * lpspiState = g_lpspiStatePtr[instance];
    LPSPI_Type *base = g_lpspiBase[instance];
    uint32_t wordToSend = 0;
    uint16_t numOfBytes;
    uint8_t availableSpace = (uint8_t)(lpspiState->fifoSize - (uint8_t)LPSPI_ReadTxCount(base));
 
    /* Fill the TX buffer. */
    while(availableSpace != 0U)
    {
        if (lpspiState->isPcsContinuous == true)
        {
            if(lpspiState->txCount == 1U)
            {
                /* Disable continuous PCS */
                LPSPI_ClearContCBit(base);
                lpspiState->txCount  = 0U;
                break;
            }
        }
        /* Get the number of bytes which can be written in a single 32 bits word. */
        if ((lpspiState->bytesPerFrame - lpspiState->txFrameCnt) <= (uint16_t)4)
        {
            numOfBytes = (uint16_t)(lpspiState->bytesPerFrame - lpspiState->txFrameCnt);
        }
        else
        {
            numOfBytes = 4U;
        }
        wordToSend = 0;
        
        if (lpspiState->txBuff != NULL)
        {
switch(lpspiState->bytesPerFrame)
{
case 1:
wordToSend = *((const uint8_t *)(lpspiState->txBuff));
lpspiState->txBuff += sizeof(uint8_t);
break;
case 2:
wordToSend = *((const uint16_t *)(lpspiState->txBuff));
lpspiState->txBuff += sizeof(uint16_t);
break;
default:
wordToSend = *((const uint32_t *)(lpspiState->txBuff));
lpspiState->txBuff += sizeof(uint32_t);
break;
}
lpspiState->txFrameCnt = (uint16_t)((lpspiState->txFrameCnt + numOfBytes) % lpspiState->bytesPerFrame);
        }
        LPSPI_WriteData(base, wordToSend);
        /* Update internal variable used in transmission. */
        lpspiState->txCount = (uint16_t)(lpspiState->txCount - numOfBytes);
        /* Verify if all bytes were send. */
        if (lpspiState->txCount == 0U)
        {
            break;
        }
    availableSpace = (uint8_t)(availableSpace - 1U);
    }
}
 
144w's fifosize is 4, maybe this reason?
0 Kudos
Reply
1,808 Views
PavelL
NXP Employee
NXP Employee

Hello @tyty697 ,

Thank you for the update and the waveform.

Yes, you are correct - the FIFO size of 4 words on S32K144W is indeed related to the observed SCLK burst behavior. Each burst corresponds to the driver filling the FIFO with up to 4 bytes (given Bits/frame = 8), and the delay between bursts is caused by the refill process in interrupt mode.

To reduce these gaps, we recommend either switching to DMA-based transfer or increasing the Bits/frame setting (e.g., to 16 or 32), if your SPI slave supports wider frame sizes.

Best regards,

Pavel

0 Kudos
Reply
1,785 Views
tyty697
Contributor II

Hello,@PaveIL

Thanks for your response,DMA has sloved this problem.But l have other problem.

l want to read six channels of ADC chip,so l use function LPSPI_DRV_MasterTransferBlocking to communicate by SPI BUS.But when l call this function contiously, There is a interval between two calls like this formwave.

66fa43ae75734e579c1e68ed7b37cda7.png66fa43ae75734e579c1e68ed7b37cda7.png

One Time I need to send 5 bytes,send 6 times to read 6 channels.If I send 30 bytes one time,ADC chip can't response right data.What can I do to decrease this interval?

0 Kudos
Reply
1,769 Views
PavelL
NXP Employee
NXP Employee

Hello @tyty697 ,

Just a general hint: 

You may try switch to the non-blocking DMA API (LPSPI_DRV_MasterTransfer) and chaining the transfers without CPU intervention. This allows for near-continuous SPI communication and better timing control.

Best regards,

Pavel

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2174984%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K144W%20SPI%20SCLK%20%EF%BC%8Cdelay%20after%20four%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2174984%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThis%20is%20my%20SPI1%20config%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-24%20184848.png%22%20style%3D%22width%3A%20997px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-24%20184848.png%22%20style%3D%22width%3A%20997px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358322i4792C4D260E58606%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-24%20184848.png%22%20alt%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-24%20184848.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3E%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-24%20184848.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20will%20transfer%2040%20bytes%3C%2FP%3E%3CP%3ELPSPI_DRV_MasterTransferBlocking(INST_LPSPI_1%2C%20config_arr%2C%20rx_buff%2C%2040%2C%20OSIF_WAIT_FOREVER)%3B%3C%2FP%3E%3CP%3EThis%20is%20wave%20of%20SCLK.I%20wish%20SCLK%20is%20contious.TDR%20and%20RDR%20is%2032%20bits%2Cdoes%20it%20have%20anything%20to%20do%20with%20it%3FWhat%20can%20I%20do%20to%20slove%20this%20problem%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%229749e2626aec43a7b43e1a9b7a968e8a.png%22%20style%3D%22width%3A%20720px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%229749e2626aec43a7b43e1a9b7a968e8a.png%22%20style%3D%22width%3A%20720px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358323i277C58C4FF3A5FC6%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%229749e2626aec43a7b43e1a9b7a968e8a.png%22%20alt%3D%229749e2626aec43a7b43e1a9b7a968e8a.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3E9749e2626aec43a7b43e1a9b7a968e8a.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2176616%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144W%20SPI%20SCLK%20%EF%BC%8Cdelay%20after%20four%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2176616%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F255187%22%20target%3D%22_blank%22%3E%40tyty697%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EJust%20a%20general%20hint%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20try%20switch%20to%20the%20non-blocking%20DMA%20API%20(LPSPI_DRV_MasterTransfer)%20and%20chaining%20the%20transfers%20without%20CPU%20intervention.%20This%20allows%20for%20near-continuous%20SPI%20communication%20and%20better%20timing%20control.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3EPavel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2176336%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144W%20SPI%20SCLK%20%EF%BC%8Cdelay%20after%20four%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2176336%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%40PaveIL%3C%2FP%3E%3CP%3EThanks%20for%20your%20response%2CDMA%20has%20sloved%20this%20problem.But%20l%20have%20other%20problem.%3C%2FP%3E%3CP%3El%20want%20to%20read%20six%20channels%20of%20ADC%20chip%2Cso%20l%20use%20function%26nbsp%3BLPSPI_DRV_MasterTransferBlocking%20to%20communicate%20by%20SPI%20BUS.But%20when%20l%20call%20this%20function%20contiously%2C%20There%20is%20a%20interval%20between%20two%20calls%20like%20this%20formwave.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2266fa43ae75734e579c1e68ed7b37cda7.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%2266fa43ae75734e579c1e68ed7b37cda7.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358661iC1CD7FEB46DD728C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2266fa43ae75734e579c1e68ed7b37cda7.png%22%20alt%3D%2266fa43ae75734e579c1e68ed7b37cda7.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3E66fa43ae75734e579c1e68ed7b37cda7.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EOne%20Time%20I%20need%20to%20send%205%20bytes%2Csend%206%20times%20to%20read%206%20channels.If%20I%20send%2030%20bytes%20one%20time%2CADC%20chip%20can't%20response%20right%20data.What%20can%20I%20do%20to%20decrease%20this%20interval%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2175609%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144W%20SPI%20SCLK%20%EF%BC%8Cdelay%20after%20four%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2175609%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F255187%22%20target%3D%22_blank%22%3E%40tyty697%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20the%20update%20and%20the%20waveform.%3C%2FP%3E%0A%3CP%3EYes%2C%20you%20are%20correct%20-%20the%20FIFO%20size%20of%204%20words%20on%20S32K144W%20is%20indeed%20related%20to%20the%20observed%20SCLK%20burst%20behavior.%20Each%20burst%20corresponds%20to%20the%20driver%20filling%20the%20FIFO%20with%20up%20to%204%20bytes%20(given%20Bits%2Fframe%20%3D%208)%2C%20and%20the%20delay%20between%20bursts%20is%20caused%20by%20the%20refill%20process%20in%20interrupt%20mode.%3C%2FP%3E%0A%3CP%3ETo%20reduce%20these%20gaps%2C%20we%20recommend%20either%20switching%20to%20DMA-based%20transfer%20or%20increasing%20the%20Bits%2Fframe%20setting%20(e.g.%2C%20to%2016%20or%2032)%2C%20if%20your%20SPI%20slave%20supports%20wider%20frame%20sizes.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3EPavel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2175324%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144W%20SPI%20SCLK%20%EF%BC%8Cdelay%20after%20four%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2175324%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ENow%20I%20clicked%20pcs%20contious%2Cthis%20is%20spi%20config%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-25%20090321.png%22%20style%3D%22width%3A%20989px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-25%20090321.png%22%20style%3D%22width%3A%20989px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358402iEB37AAD1BF3BF0F0%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-25%20090321.png%22%20alt%3D%22%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-25%20090321.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3E%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202025-09-25%20090321.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ESet%20PCSSCLK%20and%20sclkpcs%201%2C1%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3CP%3ELPSPI_DRV_MasterSetDelay(INST_LPSPI_1%2C%201%2C%201%2C%201)%3B%3C%2FP%3E%3CP%3EPCS%20and%20sclk%20waveform%20shows%20here%3C%2FP%3E%3CP%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%221d05c04a3f364e20b74d4babbc6c6396.png%22%20style%3D%22width%3A%20417px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%221d05c04a3f364e20b74d4babbc6c6396.png%22%20style%3D%22width%3A%20417px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358401i5A15BF96D151407B%2Fimage-dimensions%2F417x313%3Fv%3Dv2%22%20width%3D%22417%22%20height%3D%22313%22%20role%3D%22button%22%20title%3D%221d05c04a3f364e20b74d4babbc6c6396.png%22%20alt%3D%221d05c04a3f364e20b74d4babbc6c6396.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3E1d05c04a3f364e20b74d4babbc6c6396.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%229924e180-8b6c-4417-9cff-3158b9148dee.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%229924e180-8b6c-4417-9cff-3158b9148dee.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358404i9C1A27C405535348%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%229924e180-8b6c-4417-9cff-3158b9148dee.png%22%20alt%3D%229924e180-8b6c-4417-9cff-3158b9148dee.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3E9924e180-8b6c-4417-9cff-3158b9148dee.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EDelay%20after%20four%20bytes%20too.%20I%20see%20this%20function%20used%20in%20the%20spi%20IRQHandler%20when%20TX%20Data%20Flag%3C%2FP%3E%3CDIV%3E%2F*!%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B*%20%40brief%20Fill%20up%20the%20TX%20FIFO%20with%20data.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B*%20This%20function%20fills%20up%20the%20TX%20FIFO%20with%20data%20based%20on%20the%20bytes%2Fframe.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B*%20This%20is%20not%20a%20public%20API%20as%20it%20is%20called%20from%20other%20driver%20functions.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B*%2F%3C%2FDIV%3E%3CDIV%3Evoid%20LPSPI_DRV_FillupTxBuffer(uint32_t%20instance)%3C%2FDIV%3E%3CDIV%3E%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Instantiate%20local%20variable%20of%20type%20dspi_master_state_t%20and%20point%20to%20global%20state.%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20lpspi_state_t%20*%20lpspiState%20%3D%20g_lpspiStatePtr%5Binstance%5D%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20LPSPI_Type%20*base%20%3D%20g_lpspiBase%5Binstance%5D%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint32_t%20wordToSend%20%3D%200%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint16_t%20numOfBytes%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint8_t%20availableSpace%20%3D%20(uint8_t)(lpspiState-%26gt%3BfifoSize%20-%20(uint8_t)LPSPI_ReadTxCount(base))%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Fill%20the%20TX%20buffer.%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20while(availableSpace%20!%3D%200U)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20(lpspiState-%26gt%3BisPcsContinuous%20%3D%3D%20true)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if(lpspiState-%26gt%3BtxCount%20%3D%3D%201U)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%2F*%20Disable%20continuous%20PCS%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20LPSPI_ClearContCBit(base)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20lpspiState-%26gt%3BtxCount%26nbsp%3B%20%3D%200U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20break%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%2F*%20Get%20the%20number%20of%20bytes%20which%20can%20be%20written%20in%20a%20single%2032%20bits%20word.%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20((lpspiState-%26gt%3BbytesPerFrame%20-%20lpspiState-%26gt%3BtxFrameCnt)%20%26lt%3B%3D%20(uint16_t)4)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20numOfBytes%20%3D%20(uint16_t)(lpspiState-%26gt%3BbytesPerFrame%20-%20lpspiState-%26gt%3BtxFrameCnt)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20numOfBytes%20%3D%204U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20wordToSend%20%3D%200%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20(lpspiState-%26gt%3BtxBuff%20!%3D%20NULL)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eswitch(lpspiState-%26gt%3BbytesPerFrame)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ecase%201%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EwordToSend%20%3D%20*((const%20uint8_t%20*)(lpspiState-%26gt%3BtxBuff))%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ElpspiState-%26gt%3BtxBuff%20%2B%3D%20sizeof(uint8_t)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ebreak%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ecase%202%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EwordToSend%20%3D%20*((const%20uint16_t%20*)(lpspiState-%26gt%3BtxBuff))%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ElpspiState-%26gt%3BtxBuff%20%2B%3D%20sizeof(uint16_t)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ebreak%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Edefault%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EwordToSend%20%3D%20*((const%20uint32_t%20*)(lpspiState-%26gt%3BtxBuff))%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ElpspiState-%26gt%3BtxBuff%20%2B%3D%20sizeof(uint32_t)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ebreak%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ElpspiState-%26gt%3BtxFrameCnt%20%3D%20(uint16_t)((lpspiState-%26gt%3BtxFrameCnt%20%2B%20numOfBytes)%20%25%20lpspiState-%26gt%3BbytesPerFrame)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20LPSPI_WriteData(base%2C%20wordToSend)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%2F*%20Update%20internal%20variable%20used%20in%20transmission.%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20lpspiState-%26gt%3BtxCount%20%3D%20(uint16_t)(lpspiState-%26gt%3BtxCount%20-%20numOfBytes)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%2F*%20Verify%20if%20all%20bytes%20were%20send.%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20(lpspiState-%26gt%3BtxCount%20%3D%3D%200U)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20break%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20availableSpace%20%3D%20(uint8_t)(availableSpace%20-%201U)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E144w's%20fifosize%20is%204%2C%20maybe%20this%20reason%3F%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2175010%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144W%20SPI%20SCLK%20%EF%BC%8Cdelay%20after%20four%20bytes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2175010%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F255187%22%20target%3D%22_blank%22%3E%40tyty697%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20sharing%20the%20configuration%20and%20waveform%20details.%3C%2FP%3E%0A%3CP%3EBased%20on%20your%20setup%2C%20the%20observed%20delay%20in%20SCLK%20after%20every%204%20bytes%20is%20likely%20caused%20by%20the%20PCS%20continuous%20setting%20being%20disabled.%20When%20this%20option%20is%20unchecked%2C%20the%20chip%20select%20(PCS)%20signal%20is%20deasserted%20between%20frames%2C%20which%20introduces%20gaps%20in%20the%20SCLK%20waveform.%3C%2FP%3E%0A%3CP%3ETo%20achieve%20a%20continuous%20SCLK%20during%20the%20entire%2040-byte%20transfer%2C%20we%20recommend%20enabling%20the%20PCS%20continuous%20option%20in%20your%20LPSPI%20master%20configuration.%20This%20will%20keep%20PCS%20asserted%20throughout%20the%20transfer%20and%20eliminate%20the%20inter-frame%20delays.%3C%2FP%3E%0A%3CP%3EIf%20your%20SPI%20slave%20supports%20wider%20frame%20sizes%2C%20you%20may%20increase%20the%20Bits%2Fframe%20setting%20(e.g.%2C%20to%2016%20or%2032)%20to%20reduce%20the%20number%20of%20frames%20and%20potentially%20eliminate%20the%20gaps%20in%20SCLK%20caused%20by%20PCS%20toggling%20or%20FIFO%20refill%20latency.%3C%2FP%3E%0A%3CP%3EAdditionally%2C%20consider%20using%20DMA-based%20transfer%20instead%20of%20the%20blocking%20interrupt-based%20API.%20DMA%20can%20help%20maintain%20a%20smoother%20data%20flow%20and%20reduce%20latency%20between%20FIFO%20refills.%3C%2FP%3E%0A%3CP%3EFor%20future%20measurements%2C%20we%20kindly%20ask%20you%20to%20also%20include%20the%20PCS%20signal%20in%20the%20waveform%20capture.%20This%20will%20help%20us%20better%20understand%20the%20timing%20behavior%20and%20interactions%20between%20PCS%20and%20SCLK.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3EPavel%3C%2FP%3E%3C%2FLINGO-BODY%3E