cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3DSH I2C Communication Issue

Terence D
Senior
Posted on May 24, 2018 at 18:36

I'm trying to use the LIS3DSH accelerometer with a TI TM4C1294 development board and running into some issues.  I'm using I2C communication between the accelrometer and TM4C.  I have a fairly simple code example attached, which queries multiple registers and reports them to a terminal using UART program (screenshot below).

As can be seen in the terminal program, the values read by the software frequently differ from iteration to iteration.  I expect to be getting 0x3F for ''who am I'', 0x21 for ''info1'' and probably 0x0F for ''status''.  Based on what's displayed (in the Putty terminal screenshot), it looks like I'm reading the data register at improper times???...

However, comparing my logic analyzer info with the timing diagram on page 15 of the

http://www.st.com/content/ccc/resource/technical/document/datasheet/23/c3/ea/bf/8f/d9/41/df/DM00040962.pdf/files/DM00040962.pdf/jcr:content/translations/en.DM00040962.pdf

, I don't see any issues.  A screenshot of the logic analyzer results are shown below.

I've captured many instances of the I2C communication for this example and it always is exactly as shown in the screenshot below.  I always see the expected 0x3F and 0x21 values for ''who am I'' and ''info1'', and always see 0x00 for ''status''.  Though I would expect to see 0x0F for status, it is possible 0x00 is a valid value.

If anyone has any ideas what might be happening, I'd very much appreciate your feedback.  Thank you.

0690X0000060BLdQAM.png0690X0000060BMbQAM.png

#lis3dsh #i2c
3 REPLIES 3
Winfred LU
ST Employee
Posted on May 25, 2018 at 08:40

Hi Terence,

According to the logic analyzer logs, the I2C communication works well.

Maybe there is something wrong with the UART printing? But i could not figure it out with the provided main.c

Is it possible to debug with JTAG, and watch variables whoAmI, info1, status step by step?

By the way,

status (27h) being 0 would be valid since the sensor is powered down.

Best Regards,

Winfred

Posted on May 27, 2018 at 17:51

Thanks Winfred.  I've gotten it to reliably work by introducing some additional delays between the I2C Tiva Peripheral Lib I2C function calls.

Actually, with respect to 0x27 (status register), in my experience, the sensor is not powered down.  As long as there is power running to the sensor it is good to go by default - you can read all CTRL_REG registers as well as the OUT_X, OUT_Y, OUT_Z.  It appears the value of zero was simply due to my I2C communication issues.

Posted on May 28, 2018 at 06:53

Hi Terence,

Great to know that it works for you.

OK for the STATUS register. I think by default the sensor is powered down because in CTRL_REG4, ODR should be 0.

Anyway, this would not be an issue if it has already worked.

Best Regards,

Winfred