s32k142 spi receving no data by LPSPI_DRV_SlaveTransfer

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

s32k142 spi receving no data by LPSPI_DRV_SlaveTransfer

Jump to solution
2,145 Views
nanjun
Contributor III

Hello NXP Team,

the example lpspi_transfer_s32k142 operates properly where two spi ports are configured on the same eval-board, a screen shot is made as fig1.

However, I would like to use the slave to receive data (100 bytes) coming from the master on IMXRT1064 but it fails. No rx-interrupt in slave was triggered at all by checking slave_rx_cnt, while  it increases in the example.

For simplicity I set the BUFFER_SIZE of the slave to 1. Frame size is 8 bit.

The data from master is shown as fig2. where could the problem come from?

the code is attached here and I just let LPSPI_DRV_SlaveTransfer running :

......

LPSPI_DRV_SlaveInit(RECEIVE, &slaveState, &Receive_SlaveConfig0);
int main_cnt = 0;

LPSPI_DRV_MasterSetDelay(SEND, 1, 1, 1);
while (1)
{
/*set LPSPI_TX_DATA_FLAG and LPSPI_RX_DATA_FLAG irq tx --> irq rx if no send, only enter irq tx */
LPSPI_DRV_SlaveTransfer(RECEIVE, &slaveDataSend, &slaveDataReceive, BUFFER_SIZE);

printf("slave_rx_cnt = %d\r\n", slave_rx_cnt);

}

Thanks in advance.

Kind regards,

Neo

 

0 Kudos
Reply
1 Solution
2,123 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Neo,

Tried to send data from slave, does the master be able to received data from slave?

Please first power on the Slave, and then power on the IMXRT1064.
Can you assure that the LPSPI_DRV_SlaveTransfer function was called before master start the SPI sent out function?

This is important because our drivers are implemented in a method that if the LPSPI_DRV_SlaveTransfer function was not called before master start communication, then it can occur the behavior that you see where the Receive data is not received.

During debug, check the return of LPSPI_DRV_SlaveTransfer:
* @return STATUS_SUCCESS if driver starts to send/receive data successfully.
* STATUS_ERROR if driver is error and needs to clean error.
* STATUS_BUSY if a transfer is in progress

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
1 Reply
2,124 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Neo,

Tried to send data from slave, does the master be able to received data from slave?

Please first power on the Slave, and then power on the IMXRT1064.
Can you assure that the LPSPI_DRV_SlaveTransfer function was called before master start the SPI sent out function?

This is important because our drivers are implemented in a method that if the LPSPI_DRV_SlaveTransfer function was not called before master start communication, then it can occur the behavior that you see where the Receive data is not received.

During debug, check the return of LPSPI_DRV_SlaveTransfer:
* @return STATUS_SUCCESS if driver starts to send/receive data successfully.
* STATUS_ERROR if driver is error and needs to clean error.
* STATUS_BUSY if a transfer is in progress

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply