S32K148 LPSPI unexpected data

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

S32K148 LPSPI unexpected data

跳至解决方案
3,553 次查看
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 项奖励
回复
1 解答
3,541 次查看
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 项奖励
回复
4 回复数
3,542 次查看
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 项奖励
回复
2,865 次查看
semiconductor_user
Contributor III

@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 项奖励
回复
2,859 次查看
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 项奖励
回复
2,848 次查看
semiconductor_user
Contributor III

@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 项奖励
回复