Connecting two sensors to the same SPI bus - possible contention
Hi,
In our system there's an LSM6DSL accelerometer and LPS22HH barometer connected to the same SPI bus.
When nCS of the accelerometer is asserted (0), the nCS of the barometer is de-asserted (1) and vice versa.
HOWEVER, as nCS=1 (for both sensors) also means that the components works in I2C mode, the following condition occurs (as an example):
- nCS_Acc = 0, nCS_Baro = 1 : an attempt to communicate with the accelerometer
- MCU (STM32F412) communicates over SPI - it drives MOSI & SCLK with the relevant acceleromter command
- Concurrently to the accelerometer, the barometer which is now in I2C mode, receives the MOSI & SCLK signals on its SDA & SCL lines
- The accelerometer responds as expected on SDO towards the MCU MISO
- Now, if the barometer interpret the SPI communication to its peer as a valid I2C address byte it ACK on the SDA line, (which is shared with MOSI) and make a bus contention and mess up the communication for both sensors....
My questions are:
- Do I understand correctly or did I oversee something?
- How can we avoid a such potential contention/communcation mess up?
Thanks for any advice
