How to use S32K116 SPI read multi-byte with LPSPI0 driver?

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

How to use S32K116 SPI read multi-byte with LPSPI0 driver?

ソリューションへジャンプ
1,153件の閲覧回数
basicios
Contributor I

I have a problem with S32K116 SPI read operation. In LPSPI driver, I find there is an API  LPSPI_DRV_MasterTransferBlocking() for SPI transfer.

basicios_0-1694678617393.png

Both send and receive buffer sizes are controlled by uint16 TransferByteCount.

This means, I can only send n bytes and read back n bytes in each SPI operation.

This confuses me: the amounts sent and received are the same. I can't read more data than I can write.

For example, the device has an SPI protocol as fellow. If I want to communicate via S32K116 LPSPI, read 2 bytes after writing 1 byte. How do I do this via the LPSPI driver?

basicios_2-1694679295309.png

 

This problem has troubled me for a long time.

If you have a solution, please tell me. Thank you.

 

ラベル(1)
タグ(2)
0 件の賞賛
返信
1 解決策
1,116件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @basicios,

With the driver, and with the CS asserted between the write and the read operations, you need to call the API only once.

Set the TransferByteCount to 3 and fill the sendBuffer with 0x05, 0xFF, 0xFF (as per the format you posted).

You will receive 3 bytes, but the first byte should be ignored.

 

Regards,

Daniel

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
978件の閲覧回数
basicios
Contributor I

It work now. Thanks a lot!

0 件の賞賛
返信
1,117件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @basicios,

With the driver, and with the CS asserted between the write and the read operations, you need to call the API only once.

Set the TransferByteCount to 3 and fill the sendBuffer with 0x05, 0xFF, 0xFF (as per the format you posted).

You will receive 3 bytes, but the first byte should be ignored.

 

Regards,

Daniel

0 件の賞賛
返信