Connecting two sensors to the same SPI bus - possible contention
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-14 8:08 AM
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
Solved! Go to Solution.
- Labels:
-
Accelerometers
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-15 12:12 AM
Hi @Community member​ ,
you are in theory right, there could be some undesired cross talk between the sensors. But it is a remote possibility.
Namely, please note that:
- The I2C and the SPI are different protocols, often running at different clock speeds, and the first one needs a precise salve address and acknowledges to be effective (i.e. to trigger the digital communication block in the sensors' ASIC).
- You can however prevent a "false-positive" I2C running setting the device as follows:
Please let me know if everything is working.
-Eleon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-15 12:12 AM
Hi @Community member​ ,
you are in theory right, there could be some undesired cross talk between the sensors. But it is a remote possibility.
Namely, please note that:
- The I2C and the SPI are different protocols, often running at different clock speeds, and the first one needs a precise salve address and acknowledges to be effective (i.e. to trigger the digital communication block in the sensors' ASIC).
- You can however prevent a "false-positive" I2C running setting the device as follows:
Please let me know if everything is working.
-Eleon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-15 1:16 AM
Thanks!
This was very helpful.
