cancel
Showing results for 
Search instead for 
Did you mean: 

Can I safely use LIS3DH on a common SPI bus?

ASpen
Associate II

I am having a problem with an LIS3DH device on a common SPI bus with a serial flash memory chip. I am wondering if I may be doing something that I should not.

The two devices share a common SPI bus (SPC, SDI and SDO). The LIS3DH and the memory each have individual CS lines.

All works fine until I try to access particular memory locations in the serial flash. It seems as if the LSI3DH is, while it's CS is high, listening to the SPC and SDI lines and treating them like I2C SCL and SDA lines. Then under very particular pattern conditions, when I would have liked the LIS3DH to remain "silent", it detects an I2C Start condition. And so, some number of clock cycles later, I see the SDI (SDA) line being pulled down (fighting against the microcontroller, which was trying to keep it high at that point.)

I am thinking that, because the "CS" line on the LIS3DH is really an interface mode selector (I2C/SPI), it is unsafe to use LIS3DH devices on a common SPI bus (with ANY other device)

Any comments/observations on this situation would be much appreciated.

5 REPLIES 5
Miroslav BATEK
ST Employee

SPI communication should not looks like I2C, but I already saw this issue on the forum some time ago.

Please check this FAQ: https://community.st.com/s/article/FAQ-How-can-I-disable-I2C-of-LIS2DH12

You can use the same procedure for LIS3DH and disable the I2C interface, this should solve your issue.

ASpen
Associate II

Thanks! This fixed the problem.

While "SPI communication should not looks like I2C" it very definitely DID happen. In my product the problem only happened after 4 days of 10-second data logging to the SPI flash memory. When it got to writing to address 0x013200 (and, as I later found, also 0x033200, 0x053200 etc) the SPC and SDI line activity happened to look like I²C activity. The LIS3DH responded to this and messed up the data logging.

I would very strongly recommend that ST amend the LIS3DH datasheet. A warning should be added that : using pin 8 as if it were a normal SPI CS line, when multiple SPI devices are on the same SPC/SDI/SDO bus, is NOT safe. In addition, documentation on use of register 0x17 in disabling the I²C functionality, as the above link details, would be vital.

(The introduction of register 0x1E documentation between datasheet Rev 1 and Rev 2 was obviously a similar case.)

Miroslav BATEK
ST Employee

I see, thank you for the information.

Jeremi Wójcicki
Associate II

I have the same problem but the FAQ link is dead and I didn't find anything equivalent on google. Could sb provide a working link to the solution?

The answer in the dead link was something along the lines of :

I²C on the LIS3DH must be disabled. This is done by setting bit7 of the undocumented register 0x17.

My code looks like this

#define ACC_CTRL_UNDOC       0x17

 _CS_ACCEL = 0;

 RdWrSPI(ACC_READ | ACC_CTRL_UNDOC);

 tmp = RdWrSPI(0x00);

 _CS_ACCEL = 1;

 Delay10uS(1);

 WriteToAccelerometer(ACC_CTRL_UNDOC, tmp | 0x80);