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.
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.
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
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:
So, it's bytesRemained dosn't express the data received sucessfully.
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.