S32K146 LPSPI transfer bytes

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K146 LPSPI transfer bytes

2,193件の閲覧回数
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,169件の閲覧回数
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,161件の閲覧回数
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,149件の閲覧回数
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 件の賞賛
返信