2018-05-24 09:36 AM
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
, 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.
#lis3dsh #i2c2018-05-24 11:40 PM
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
2018-05-27 10:51 AM
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.
2018-05-27 11:53 PM
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