Skip to main content
Visitor II
July 11, 2024
Solved

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

  • July 11, 2024
  • 2 replies
  • 1376 views
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!
 
 
 
 
 
 
    This topic has been closed for replies.
    Best answer by TDK

    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.

    2 replies

    TDKAnswer
    Super User
    July 11, 2024

    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.

    coderAuthor
    Visitor II
    July 19, 2024

    Thanks for the response.