S32K146 LPSPI transfer bytes

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K146 LPSPI transfer bytes

2,199 次查看
lc12138
Contributor II

Hi,

I try to transfer and receive 28-bytes data with s32k146.And I used the code as follow:

LPSPI_DRV_MasterTransfer(INST_LPSPI_2, masterDataSend, masterDataReceive, BUFFER_SIZE);
flag = ( LPSPI_DRV_MasterGetTransferStatus(INST_LPSPI_2, bytesRemained) == STATUS_SUCCESS);

masterDataSend is data which I want to send and masterDataReceive is which I want to receive,BUFFER_SIZE is set to 28u.

However, while flag is true the bytesRemained is 0,and Receive buff is all 1.

Is anything in my conde wrong?And how could I find problem.

Thanks

0 项奖励
回复
3 回复数

2,175 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

The source code in that .rar file is not readable.

Can you attach it again?

Regarding the code that you posted here,

flag = ( LPSPI_DRV_MasterGetTransferStatus(INST_LPSPI_2, bytesRemained) == STATUS_SUCCESS);

The function will not return STATUS_SUCCESS immediately.

Can you use something like this intead?

LPSPI_DRV_MasterTransfer(INST_LPSPI_2, masterDataSend, masterDataReceive, BUFFER_SIZE);
while(LPSPI_DRV_MasterGetTransferStatus(INST_LPSPI_2, bytesRemained) != STATUS_SUCCESS);

If you want to receive all the data transmitted by the master, connect MOSI to MISO in a loop.

Have you scoped the SPI bus with a logic analyzer?

 

BR, Daniel

 

 

0 项奖励
回复

2,167 次查看
lc12138
Contributor II

Thanks,

I tried to use 

while(LPSPI_DRV_MasterGetTransferStatus(INST_LPSPI_2, bytesRemained) != STATUS_SUCCESS);

but bytesRemained is still 0.

I sent a 9-bytes 0x55 to a LTC6820, and I used a oscilloscope to scope the SPI bus in 6820 sideMOSI(4bytes)MOSI(4bytes)MISO(4bytes)MISO(4bytes)MISO(9bytes)MISO(9bytes)

you could see that MOSI signal is actually 0x55, but MISO signal is not good, although its also 9 bytes.

0 项奖励
回复

2,155 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @lc12138,

Can you disconnect the LTC6820 and connect MOSI - MISO instead?

Just to test the code.

 

BR, Daniel

0 项奖励
回复