ImxRT 1176 LPSPI blocking function issue

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

ImxRT 1176 LPSPI blocking function issue

Jump to solution
1,127 Views
chandan_uv
Contributor III

Hello, I’m working with LPSPI and using LPSPI_MasterTransferBlocking. Since this is a blocking function, I expect the LPSPI peripheral to be free once the transfer is complete. However, I observed something different.

After the blocking transfer, I read the SR (Status Register) using LPSPI_GetStatusFlags, and the returned value was 0x1001101.

Do you have any suggestions? Ideally, after the blocking transfer, the LPSPI should be idle. I’m sharing a code snapshot below for reference. 

 

    if((staus_flag & kLPSPI_ModuleBusyFlag) == kLPSPI_ModuleBusyFlag)
    {
        ret = STATUS_BUSY;
        PRINTF("SPI Busy, %x, %d\r\n", staus_flag, count);
    }
    else
    {
        masterXfer.txData   = SpiTxData;
        masterXfer.rxData   = SpiRxData;
        masterXfer.dataSize = spiTransferSize;
        masterXfer.configFlags =
        kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous;
        status = LPSPI_MasterTransferBlocking(LPSPI1, &masterXfer);
        ret = STATUS_SUCCESS;
        staus_flag = LPSPI_GetStatusFlags(IMU_SPI_IF);
        PRINTF("staus_flag: %x\r\n", staus_flag);
        count++;
        //sw_asm_delay_us(2U);
    }

 

 

0 Kudos
Reply
1 Solution
1,085 Views
mayliu1
NXP Employee
NXP Employee

Hi @chandan_uv ,

Thank you so much for your interest in our products and for using our community.

Question: 

After the blocking transfer, I read the SR (Status Register) using LPSPI_GetStatusFlags, and the returned value was 0x1001101.

Answer: I check your LPSPI SR register value is 0x1001101,

that is 0b0001 0000 0000 0001 0001 0000 0001, the TCF (Transfer Complete Flag) is 0,which means Transfer  Not complete.

From IMXRT1170RM,  we can see the detail SR status TCF  description. In Master mode, indicates that all transfers have completed and that LPSPI has returned to Idle state and the transmit FIFO is empty.

mayliu1_0-1745547395328.png

Question:

Do you have any suggestions? Ideally, after the blocking transfer, the LPSPI should be idle. I’m sharing a code snapshot below for reference. 

Answer:

I suggest you can develop your project based on SDK demo.

Please Verify the frame format configuration: 
Make sure that the LPSPI settings (For example: Data Length, CPOL, CPHA) of the master device are exactly same to the slave device.

 

Wish it helps you.
If you still have question about it, please kindly let me know.

Wish you a nice day!

Best Regards
MayLiu

View solution in original post

0 Kudos
Reply
2 Replies
1,086 Views
mayliu1
NXP Employee
NXP Employee

Hi @chandan_uv ,

Thank you so much for your interest in our products and for using our community.

Question: 

After the blocking transfer, I read the SR (Status Register) using LPSPI_GetStatusFlags, and the returned value was 0x1001101.

Answer: I check your LPSPI SR register value is 0x1001101,

that is 0b0001 0000 0000 0001 0001 0000 0001, the TCF (Transfer Complete Flag) is 0,which means Transfer  Not complete.

From IMXRT1170RM,  we can see the detail SR status TCF  description. In Master mode, indicates that all transfers have completed and that LPSPI has returned to Idle state and the transmit FIFO is empty.

mayliu1_0-1745547395328.png

Question:

Do you have any suggestions? Ideally, after the blocking transfer, the LPSPI should be idle. I’m sharing a code snapshot below for reference. 

Answer:

I suggest you can develop your project based on SDK demo.

Please Verify the frame format configuration: 
Make sure that the LPSPI settings (For example: Data Length, CPOL, CPHA) of the master device are exactly same to the slave device.

 

Wish it helps you.
If you still have question about it, please kindly let me know.

Wish you a nice day!

Best Regards
MayLiu

0 Kudos
Reply
1,124 Views
chandan_uv
Contributor III

BTW LPSPI1 and IMU_SPI_IF is same.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2086405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EImxRT%201176%20LPSPI%20blocking%20function%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2086405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%20I%E2%80%99m%20working%20with%20LPSPI%20and%20using%20LPSPI_MasterTransferBlocking.%20Since%20this%20is%20a%20blocking%20function%2C%20I%20expect%20the%20LPSPI%20peripheral%20to%20be%20free%20once%20the%20transfer%20is%20complete.%20However%2C%20I%20observed%20something%20different.%3C%2FP%3E%3CP%3EAfter%20the%20blocking%20transfer%2C%20I%20read%20the%20SR%20(Status%20Register)%20using%20LPSPI_GetStatusFlags%2C%20and%20the%20returned%20value%20was%200x1001101.%3C%2FP%3E%3CP%3EDo%20you%20have%20any%20suggestions%3F%20Ideally%2C%20after%20the%20blocking%20transfer%2C%20the%20LPSPI%20should%20be%20idle.%20I%E2%80%99m%20sharing%20a%20code%20snapshot%20below%20for%20reference.%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%20%20%20%20if((staus_flag%20%26amp%3B%20kLPSPI_ModuleBusyFlag)%20%3D%3D%20kLPSPI_ModuleBusyFlag)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20ret%20%3D%20STATUS_BUSY%3B%0A%20%20%20%20%20%20%20%20PRINTF(%22SPI%20Busy%2C%20%25x%2C%20%25d%5Cr%5Cn%22%2C%20staus_flag%2C%20count)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20masterXfer.txData%20%20%20%3D%20SpiTxData%3B%0A%20%20%20%20%20%20%20%20masterXfer.rxData%20%20%20%3D%20SpiRxData%3B%0A%20%20%20%20%20%20%20%20masterXfer.dataSize%20%3D%20spiTransferSize%3B%0A%20%20%20%20%20%20%20%20masterXfer.configFlags%20%3D%0A%20%20%20%20%20%20%20%20kLPSPI_MasterPcs0%20%7C%20kLPSPI_MasterPcsContinuous%3B%0A%20%20%20%20%20%20%20%20status%20%3D%20LPSPI_MasterTransferBlocking(LPSPI1%2C%20%26amp%3BmasterXfer)%3B%0A%20%20%20%20%20%20%20%20ret%20%3D%20STATUS_SUCCESS%3B%0A%20%20%20%20%20%20%20%20staus_flag%20%3D%20LPSPI_GetStatusFlags(IMU_SPI_IF)%3B%0A%20%20%20%20%20%20%20%20PRINTF(%22staus_flag%3A%20%25x%5Cr%5Cn%22%2C%20staus_flag)%3B%0A%20%20%20%20%20%20%20%20count%2B%2B%3B%0A%20%20%20%20%20%20%20%20%2F%2Fsw_asm_delay_us(2U)%3B%0A%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2086982%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20ImxRT%201176%20LPSPI%20blocking%20function%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2086982%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F215611%22%20target%3D%22_blank%22%3E%40chandan_uv%3C%2FA%3E%26nbsp%3B%2C%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EThank%20you%20so%20much%20for%20your%20interest%20in%20our%20products%20and%20for%20using%20our%20community.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EQuestion%3A%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EAfter%20the%20blocking%20transfer%2C%20I%20read%20the%20SR%20(Status%20Register)%20using%20LPSPI_GetStatusFlags%2C%20and%20the%20returned%20value%20was%200x1001101.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EAnswer%3A%20I%20check%20your%20LPSPI%20SR%20register%20value%20is%200x1001101%2C%20%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3Ethat%20is%200b0001%200000%200000%200001%200%3CFONT%20color%3D%22%23FF0000%22%3E0%3C%2FFONT%3E%3CFONT%20color%3D%22%23000000%22%3E0%3C%2FFONT%3E1%200000%200001%2C%20the%20TCF%20(Transfer%20Complete%20Flag)%20is%200%2Cwhich%20means%26nbsp%3BTransfer%26nbsp%3B%20Not%20complete.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EFrom%20IMXRT1170RM%2C%26nbsp%3B%20we%20can%20see%20the%20detail%20SR%20status%20TCF%26nbsp%3B%20description.%20In%20Master%20mode%2C%20indicates%20that%20all%20transfers%20have%20completed%20and%20that%20LPSPI%20has%20returned%20to%20Idle%20state%20and%20the%20transmit%20FIFO%20is%20empty.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mayliu1_0-1745547395328.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22mayliu1_0-1745547395328.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F334841i2055E0F32EB008A7%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22mayliu1_0-1745547395328.png%22%20alt%3D%22mayliu1_0-1745547395328.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EQuestion%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EDo%20you%20have%20any%20suggestions%3F%20Ideally%2C%20after%20the%20blocking%20transfer%2C%20the%20LPSPI%20should%20be%20idle.%20I%E2%80%99m%20sharing%20a%20code%20snapshot%20below%20for%20reference.%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EAnswer%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3EI%20suggest%20you%20can%20develop%20your%20project%20based%20on%20SDK%20demo.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3E%3CSPAN%3EPlease%20Verify%20the%20frame%20format%20configuration%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%20size%3D%223%22%3E%3CSPAN%3E%20Make%20sure%20that%20the%20LPSPI%20settings%20(For%20example%3A%20Data%20Length%2C%20CPOL%2C%20CPHA)%20of%20the%20master%20device%20are%20%3C%2FSPAN%3E%3CSTRONG%3Eexactly%20same%26nbsp%3B%3C%2FSTRONG%3E%3CSPAN%3Eto%20the%20slave%20device.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EWish%20it%20helps%20you.%3CBR%20%2F%3EIf%20you%20still%20have%20question%20about%20it%2C%20please%20kindly%20let%20me%20know.%3C%2FP%3E%0A%3CP%3EWish%20you%20a%20nice%20day!%3C%2FP%3E%0A%3CP%3EBest%20Regards%3CBR%20%2F%3EMayLiu%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2086408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20ImxRT%201176%20LPSPI%20blocking%20function%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2086408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EBTW%26nbsp%3BLPSPI1%20and%20IMU_SPI_IF%20is%20same.%3C%2FP%3E%3C%2FLINGO-BODY%3E