Problems about S32K144 transmit data to S32K142 by LPSPI0

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

Problems about S32K144 transmit data to S32K142 by LPSPI0

Jump to solution
3,827 Views
DELPHI_Eric
Contributor III

Hi,guys

I want to check the SPI drive, so I have used the S32DS SDK APIs to make S32K144 transmit data to S32K142 by LPSPI0.

But now I found S32k142 couldn't get the data from S32k144, I make sure the four pins setted by S32DS Processor Expert is ok, I don't konw where the problem is, so I want some help from you,the code is as follow attachment.

Thank you very much.

0 Kudos
Reply
1 Solution
3,536 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello shenjun

Could you please attach both test projects?

Thanks,

BR, Daniel

View solution in original post

0 Kudos
Reply
11 Replies
3,536 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi shenjun,

First of all, the lpspi_transfer_s32k144 SDK example demonstrates use of both LPSPI Master and Slave on a single MCU. So, there is no need to have two MCUs.

Once you have called the LPSPI_DRV_SlaveTransfer() function (S32K142), you should call the LPSPI_DRV_SlaveGetTransferStatus() until the transfer is finished before initializing another transfer.

Please check the return values of the SDK functions.  

Also, I see that you use the SDK along with a bare-metal LPSPI routines on the LPSPI0 module.

I would suggest you measure the bus with an oscilloscope.

Thanks,

BR, Daniel

0 Kudos
Reply
3,536 Views
DELPHI_Eric
Contributor III

I measured the bus with an oscilloscope.And the master out pin displayed waveform in the oscilloscope.But the salve RX FIFO is empty by check the register RSR.

0 Kudos
Reply
3,536 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Dear shenjun,

If I understand, you are testing the example on a single MCU now.

Yes, the pins of LPSPI1 and LPSPI0 modules must be connected on the board.

pastedImage_2.png

What is the return status of the LPSPI_DRV_SlaveTransfer(), LPSPI_DRV_MasterTransferBlocking() functions?

Have you tried testing the example without any modification? 

BR, Daniel

0 Kudos
Reply
3,536 Views
DELPHI_Eric
Contributor III

Dear Daniel,

Thank you for your answered in patience.But by the way , used the two MCUs beacause of the hardware board has been designed as s32k144 transfer S32k142 by lpspi0. 

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

s32k144 configure as master,

LPSPI_DRV_MasterInit(0, &masterState, &Send_MasterConfig0);

while(1)

{

   if(STATUS_SUCCESS == LPSPI_DRV_MasterTransfer(0, &slaveDataSend, &slaveDataReceive, 1))
   {
            i ++;

    }

}

pastedImage_2.png

pastedImage_3.png

All pins select the alt2 function

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

s32k142 configure as salve,

LPSPI_DRV_SlaveInit(0, &slaveState, &Receive_SlaveConfig0);

while(1)

{

    if(STATUS_SUCCESS == LPSPI_DRV_SlaveTransfer(RECEIVE, &data, &recvdate, 1))
   {
            i ++;

            temp = recvdate;

    }

}

pastedImage_1.png

pastedImage_4.png

All pins select the alt2 function

I have seen the waveform in the oscilloscope by touch the s32k144 PTE2, but the s32k142 didn't have any receive data.

0 Kudos
Reply
3,537 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello shenjun

Could you please attach both test projects?

Thanks,

BR, Daniel

0 Kudos
Reply
3,536 Views
DELPHI_Eric
Contributor III

I changed the PE configure as below,

As master s32k144:

pastedImage_1.png

pastedImage_3.png

As slave s32k142:

pastedImage_6.png

pastedImage_7.png

When I used oscilloscope to touch the master S32k144 output PTE2 during the slave S32k142 powerdown,the waveform was as follow:

pastedImage_8.png

But when slave S32k142 work ,the waveform changed as follow:

pastedImage_9.png

 

It seems that slave S32k142 has output level , so that the wave of master S32k144 output PTE2 has been influenced !

But , I just configure the S32k142 pins as a salve , the S32k144 as a master, why? Could you help me to slove this problem,thank you very much!

0 Kudos
Reply
3,536 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Just to be sure, how exactly are the two MCUs connected?  

Is S32K144 PE2 connected to S32K142 PTE1 and vice versa?

If possible, please attach the entire test projects.

Thanks,

BR, Daniel

0 Kudos
Reply
3,536 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

In the S32K142 main() function that you posted here:

https://community.nxp.com/thread/510735

You have this line:

pastedImage_1.png

Please remove it or change the HW connection accordingly.

Thanks,

BR, Daniel  

3,536 Views
DELPHI_Eric
Contributor III

Hi Daniel, 

Actually it's the HW connection problem, I have asked the hardware engineer to fix and the problem has been solved.Thank you very much.

0 Kudos
Reply
3,536 Views
DELPHI_Eric
Contributor III

OK,

All pins select the alt2 function

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

s32k142 configure as salve,

 

LPSPI_DRV_SlaveInit(0, &slaveState, &Receive_SlaveConfig0);

while(1)

{

    if(STATUS_SUCCESS == LPSPI_DRV_SlaveTransfer(RECEIVE, &data, &recvdate, 1))
   {
            i ++;

            temp = recvdate;

    }

}

pastedImage_1.png

 

pastedImage_4.png

0 Kudos
Reply
3,536 Views
DELPHI_Eric
Contributor III

Dear Daniel,

Used the two MCUs, beacause of the hardware board has been designed.By the way,demonstrates use of both LPSPI Master and Slave on a single MCU need the wires connect? Follow your advise, I code as follow ,but it cann't enter the if conditional statement.

   

/* Initialize LPSPI0 (Send)*/
LPSPI_DRV_MasterInit(SEND, &masterState, &Send_MasterConfig0);
/* Initialize LPSPI1 (Receive)*/
LPSPI_DRV_SlaveInit(RECEIVE, &slaveState, &Receive_SlaveConfig0);
/* Initialize ADC */
// ADC_DRV_ConfigConverter(INST_ADCONV1, &adConv1_ConvConfig0);
/* Initialize FTM */
// FTM_DRV_Init(INST_FLEXTIMER_PWM1, &flexTimer_pwm1_InitConfig, &ftmStateStruct);
// FTM_DRV_InitPwm(INST_FLEXTIMER_PWM1, &flexTimer_pwm1_PwmConfig);

while(1)
{
// ADC_DRV_ConfigChan(INST_ADCONV1, 0U, &adConv1_ChnConfig0);
// ADC_DRV_WaitConvDone(INST_ADCONV1);
/* Store the channel result into a local variable slaveDataSend*/
// ADC_DRV_GetChanResult(INST_ADCONV1, 0U, &adcRead);
// slaveDataSend = (uint8_t)adcRead;
slaveDataSend = (uint8_t)(0x0f);
LPSPI_DRV_SlaveTransfer(RECEIVE, &slaveDataSend, &slaveDataReceive, BUFFER_SIZE);
LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend, &masterDataReceive, BUFFER_SIZE, TIMEOUT);
// FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, masterDataReceive<<8, 0U, true);
if(0x0f == masterDataReceive)
{
uint8_t i;
i++;
}

}

0 Kudos
Reply