cancel
Showing results for 
Search instead for 
Did you mean: 

Issue Reading WHO_AM_I Register from LSM6DSV16X IMU Sensor - Incorrect Value Returned

coder
Associate
Hello,
I am working with the LSM6DSV16X IMU sensor and interfacing it using SPI mode 3 on an STM32 microcontroller(STM32F446RE) with STM32CubeIDE. My SPI configuration is set with CPOL = High and CPHA = 2nd edge, and I have set the baud rate prescaler to 4, resulting in a baud rate of 10 MBits/s.Before reading the WHO_AM_I register, I configure certain registers as follows:if (spi_write_register(CTRL3_REG, 0x45) != SUCCESS) return ERROR;
if (spi_write_register(FUNC_CFG_ACCESS_REG, 0x00) != SUCCESS) return ERROR;
However, when I attempt to read the WHO_AM_I register, I consistently receive 0x80 instead of the expected 0x70.Here is a summary of my setup and the issue:SPI mode: Mode 3 (CPOL = High, CPHA = 2nd edge)
Baud rate: 10 MBits/s (prescaler = 4)
Initial register configurations:
CTRL3_REG = 0x05
FUNC_CFG_ACCESS_REG = 0x00
Could anyone suggest potential reasons for this discrepancy or any troubleshooting steps I should take?
Thank you!
 
 
 
 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Do writes to other registers (i.e. CTRL3_REG) work and can you correctly read back the value you just wrote?

What hardware are you working with? Custom or a dev board of some sort?

> Could anyone suggest potential reasons for this discrepancy or any troubleshooting steps I should take?

Put a scope on the SPI lines and see if they agree with what your code returns.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

Do writes to other registers (i.e. CTRL3_REG) work and can you correctly read back the value you just wrote?

What hardware are you working with? Custom or a dev board of some sort?

> Could anyone suggest potential reasons for this discrepancy or any troubleshooting steps I should take?

Put a scope on the SPI lines and see if they agree with what your code returns.

If you feel a post has answered your question, please click "Accept as Solution".
coder
Associate

Thanks for the response.