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

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

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

跳至解决方案
1,154 次查看
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,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 项奖励
回复
2 回复数
979 次查看
basicios
Contributor I

It work now. Thanks a lot!

0 项奖励
回复
1,118 次查看
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 项奖励
回复