S32k144 transfer array to S32k142,but when set point to debug I found the sequence of data in array sometimes was wrong

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

S32k144 transfer array to S32k142,but when set point to debug I found the sequence of data in array sometimes was wrong

2,156 Views
DELPHI_Eric
Contributor III

I used master S32k144 sent uint8_t TXBuffer[8] = {0,1,2,3,4,5,6,7}; 

if(STATUS_SUCCESS == LPSPI_DRV_MasterTransfer(0, TXBuffer, RXBuffer, 8))
{


}

to slave S32k142: uint8_t RXBuffer[8] = {0};

if(STATUS_SUCCESS == LPSPI_DRV_SlaveTransfer(0, TXBuffer, RXBuffer, 8))
{

}

but the sequence of data in RXBuffer[8] is wrong,as follow, the sequence also changed not surely,sometimes it's {1,2,3,4,5,6,7,0},or {4,5,6,7,0,1,2,3},or {6,7,0,1,2,3,4,5} and so on.

pastedImage_6.png

pastedImage_7.png

 I check the clock polarity, direction of the 144 and 142 both are clock active high and lsb first. So how can I get the correct sequence of data in RXBuffer[8] as the sequence of data in TXBuffer[8] of master S32K144 sent. Is there some SDK API need to be called.Thank you very much.

Tags (1)
6 Replies

2,011 Views
DELPHI_Eric
Contributor III

Em, is there some advise.

0 Kudos
Reply

2,011 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

You are using non-blocking functions.

Please use the LPSPI_DRV_SlaveGetTransferStatus(), LPSPI_DRV_MasterGetTransferStatus() function once you initialize a transfer to check if the transfer is complete.

More information in the SDK documentation:

.../S32DS_ARM_v2018.R1/S32DS/S32SDK_S32K1xx_RTM_3.0.0/doc/Start_here.html

BR, Daniel

0 Kudos
Reply

2,011 Views
DELPHI_Eric
Contributor III

Hi Daniel,

First of all, thank you for your patience. I have tried to code follow your advise as above.The code as follow:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

master S32k144:

if(STATUS_SUCCESS == LPSPI_DRV_MasterTransfer(0, TXBuffer, RXBuffer, 8))
{
   uint32_t nbytes = 0;
   LPSPI_DRV_MasterGetTransferStatus(0, &nbytes);
   while( 8 != nbytes )
    {

    }
   OSIF_TimeDelay( 1 );
}

The nbytes of LPSPI_DRV_SlaveGetTransferStatus equal 8, it seem transfered all the 8 datas sucessfully.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

slave S32k142:

status_t sts = LPSPI_DRV_SlaveTransfer(0, TXBuffer, RXBuffer, 8);
if(STATUS_SUCCESS == sts)
{
   uint32_t nbytes;
   LPSPI_DRV_SlaveGetTransferStatus(0, &nbytes);
   if(8 == nbytes)
   { 
      for(; index < 8; index ++)
      {
         TXBuffer0[index] = RXBuffer[index];
      }

}
OSIF_TimeDelay(1);
}

The nbytes of LPSPI_DRV_SlaveGetTransferStatus always equal 4.I found the description of LPSPI_DRV_SlaveGetTransferStatus() in the SDK documentation is:

pastedImage_6.png

So, it's bytesRemained dosn't express the data received sucessfully. 

0 Kudos
Reply

2,011 Views
DELPHI_Eric
Contributor III

master S32k144:   The nbytes of LPSPI_DRV_MasterGetTransferStatus equal 8, it seem transfered all the 8 datas sucessfully.

In the result, the problem dosn't solved.

0 Kudos
Reply

2,011 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi shenjun,

Can you make sure that the slave data are initialized before the master starts the transfer?

Thanks,

BR, Daniel

0 Kudos
Reply

2,011 Views
DELPHI_Eric
Contributor III

Thank you remind,I found master's transfer frequency was too fast. When I make it slow,the slave receive data is ok.By the way,what's the maximum bytes of buffer can master send once a time.