Skip to main content
Jay Gaz
Associate
June 11, 2018
Question

Why am I getting garbage data reading from the LIS3DSH accelerometer with the STM32F407G MCU?

  • June 11, 2018
  • 2 replies
  • 1653 views
Posted on June 12, 2018 at 00:02

The original post was too long to process during our migration. Please click on the attachment to read the original post.
    This topic has been closed for replies.

    2 replies

    AvaTar
    Senior III
    June 12, 2018
    Posted on June 12, 2018 at 09:48

    However, now I only get 0xFF as the data when I debug the program.

    I suspect this indicates the slave device is not answering at all.

    Have you checked the lines with s acope ?

    What board you working on ?

    There are Discovery boards around where the connections to said accelerometer are set to I2C in hardware.

    Jay Gaz
    Jay GazAuthor
    Associate
    June 13, 2018
    Posted on June 13, 2018 at 23:50

    Since I'm so new to the embedded world, I do not have a scope yet. I'll definitely do some research and buy an oscilloscope.

    In the meantime, is there no other reliable way to detect whether the slave device is answering at all?

    I'm using the STM32F407G-DISC1 board. And it's user manual definitely states that the accelerometer uses the SPI protocol. This is what the manual says:

    The STM32F407VG microcontroller controls this motion sensor through the SPI interface.

    This is on page 17 of DocID022256 Rev 6. So I think SPI should be fine.

    Perhaps I should use the HAL driver functions first to see if the accelerometer is responding. If the works, at least I'll know that it's an issue with my code and setup of all the configurations. If it doesn't work, then I'm sure what to do at that point.

    henry.dick
    Associate II
    June 14, 2018
    Posted on June 14, 2018 at 00:29

    A logic analyzer is much more useful here.

    henry.dick
    Associate II
    June 13, 2018
    Posted on June 14, 2018 at 00:28

    Try software spi first. Once you get it going, switch to hardware spi.

    Jay Gaz
    Jay GazAuthor
    Associate
    June 14, 2018
    Posted on June 14, 2018 at 02:44

    To be honest, I'm not sure what you mean by that.

    AvaTar
    Senior III
    June 15, 2018
    Posted on June 15, 2018 at 07:42

    The SPL-based firmware package for the F4 Discovery contains example code for the MEMS sensors (including the LIS3D), e.g. the demo application.

    I would check the settings made there.