Hi NXP Tech Community,
Our customer has configured the S32K148 LPSPI PCS3 to communicate with the ST accelerometer and gyroscope, ASM330LHH. They are testing this on their prototype board.
The S32K148 MCU is reading 2 bytes, where the first byte and second byte data are 0xFF and 0x6B respectively. The first byte 0xFF is an additional byte which the data is not expected by the customer.
Customer would like to know with an example, what is the correct way of reading and writing single and multiple bytes?
Below is the snapshot of project configuration of the customer’s project.
SPI configuration

They are using Chip Select 3.

The transmit and receive buffer size are 10.

When the code is uploaded onto the MCU, it is reading 2 bytes, where the first byte and second byte data are 0xFF and 0x6B respectively. The first byte 0xFF is an additional byte which the data is not expected by the customer.


The oscilloscope is also seeing 0xFF 0x6B. The ST accelerometer and gyroscope address is 0x6B. but the first byte is not expected by the customer.
The customer’s code snippet is as below:
acl_spi2_tx_buf[0] = 0x0FU | 0x80U;//Reading: who iam //acl_spi2_tx_buf[0] = 0x0FU; //| 0x01U;//Reading: who iam //LPSPI_DRV_MasterTransferBlocking(SPI_2,acl_spi2_tx_buf,acl_spi2_rx_buf,5,OSIF_WAIT_FOREVER); LPSPI_DRV_MasterTransferBlocking(ACL_Slave_Inst,acl_spi2_tx_buf,acl_spi2_rx_buf,2,OSIF_WAIT_FOREVER); |