S32K148 LPSPI unexpected data

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

S32K148 LPSPI unexpected data

Jump to solution
1,536 Views
joshua_hong
Contributor III

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

joshua_hong_0-1610379445925.png

 

 

They are using Chip Select 3.

joshua_hong_1-1610379445951.png

 

 

 

The transmit and receive buffer size are 10.

joshua_hong_2-1610379445970.png

 

 

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.

joshua_hong_3-1610379446031.png

 

joshua_hong_4-1610379447208.png

 

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);

 

0 Kudos
Reply
1 Solution
1,524 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

 

seems the reading is correct, first 0xFF is just dummy byte SPI reads as line is held high.
Reading slave registers consist of sending 2 bytes from master, address and dummy.
2021-01-12_7-19-30.png

And so SPI is reading also 2 bytes, dummy byte (0xFF) and and register value (0x6B).

 

BR, Petr

 

View solution in original post

0 Kudos
Reply
4 Replies
1,525 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

 

seems the reading is correct, first 0xFF is just dummy byte SPI reads as line is held high.
Reading slave registers consist of sending 2 bytes from master, address and dummy.
2021-01-12_7-19-30.png

And so SPI is reading also 2 bytes, dummy byte (0xFF) and and register value (0x6B).

 

BR, Petr

 

0 Kudos
Reply
848 Views
semiconductor_user
Contributor II

@PetrS @joshua_hong can you tell me what we be a transmitting and receving frame, and how to read this frames. i mean should i send data to slave or just i read data from slave.

 

0 Kudos
Reply
842 Views
joshua_hong
Contributor III

Hi @semiconductor_user.

you can send data/command to slave first and expect slave to reply data in the same frame. refer to Petr's attached snapshot.

0 Kudos
Reply
831 Views
semiconductor_user
Contributor II

@PetrS @joshua_hong if you have sample code of this communication plz send me. so that i can understand what address and data will be transmit for getting proper reading of IMU data.

 

0 Kudos
Reply