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

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

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

Jump to solution
652 Views
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.

 

Labels (1)
Tags (2)
0 Kudos
1 Solution
615 Views
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

View solution in original post

0 Kudos
2 Replies
477 Views
basicios
Contributor I

It work now. Thanks a lot!

0 Kudos
616 Views
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 Kudos