Skip to main content
Visitor II
December 16, 2018
Question

LSM303C gives zero output values

  • December 16, 2018
  • 3 replies
  • 795 views

Hi,

I am trying to read acceleration values from ;SM303C using a MCU. The output values are always zero, even for acceleration in z-axis when the module is at rest. I made sure that LSM303C is not in power down mode by setting CTRL_REG1_A (20h) to 0x6F. Please help. Here is my code:

void IMU_State (void)

{

U8 array[1] = {0x2C};

U8 array2[1] = {0x2D};

U8 array_write[2];

int SMB_DATA_WRITE_INDEX;

SMB_DATA_WRITE_INDEX = 0;

array_write[SMB_DATA_WRITE_INDEX++] = 0x20;

array_write[SMB_DATA_WRITE_INDEX++] = 0x6F;

SMB_DATA_OUT = array_write;

TARGET = 0x3A;  /

SMB_Write();

SMB_DATA_OUT = array;

TARGET = 0x3A;  

SMB_Write();

SMB_Read();

SMB_DATA_OUT = array2;

TARGET = 0x3A;  

SMB_Write();

SMB_Read();

}

    This topic has been closed for replies.

    3 replies

    ST Employee
    December 17, 2018

    Are you able to read back the sensor configuration and WHO_AM_I register?

    NVellAuthor
    Visitor II
    December 20, 2018

    I am able to read back WHO_AM_I register correctly. However, the sensor configuration register returns a value of 0xFF even though I write a value of 0x6F. Whatever value I write, it reads back 0xFF. Here is the code for sensor configuration register:

    void IMU (void)

    {

    U8 status[1] = {0x20};

    SMB_DATA_OUT = status;

    TARGET = 0x3A;  

    SMB_Write();

    SMB_Read();

    }

    Please help.

    ST Employee
    January 6, 2019

    Is the WHO_AM_I value(s) correct? In line with datasheet?