Skip to main content
Visitor II
November 27, 2019
Question

How to connect more LSM303AH on one SPI BUS?

  • November 27, 2019
  • 10 replies
  • 3574 views

We are affraid when one device has CS signal down, other devices will be set to I2C there can be conflict on the SPI BUS. Is it possible connect more devices as eclosed schematic?

    This topic has been closed for replies.

    10 replies

    ST Employee
    November 27, 2019

    Hi @PUnze.1720​ , you should not worry about this because the SPI and I2C communication protocol are different and the SPI cannot induce an I2C communication on the device. So, ok to share the SPI lines among the sensors, except from the CSs.

    Btw, a good practice is to write the I2C_ DISABLE bit on CTRL2_A (21h) for all the devices (p.52 of the datasheet), during the initialization phase of your application, so that you prevent any I2C/SPI interference by default.

    Regards

    Visitor II
    November 28, 2019

    Do you have any recommendation for connection of 4-wire SPI master to 3-wire SPI slaves? Is it possible use enlosed schematic? If so, what value of R1?

    ST Employee
    November 28, 2019

    Yes, your schematic seems ok. A 1kOhm resistor should be ok for the master to control the slave via the resistor when the slave itself isn't driving the pin. Btw in this configuration (4-wire master, 3-wire slave) you have to implement the SPI communication in bit banging. Regards

    Visitor II
    November 28, 2019

    Thank you for fast reply!

    Visitor II
    December 29, 2019

    My testing board with 3-wire SPI devices is ready. There are more magnetometers on my board. More complicated connection of LSM9DS1 on 3.3V connected with ATXMEGA on 1.8V via level shifter works properly. But clock to LSM303AH are pulled down to level 0.9V whereas SDI_SDO are good 1.8V level. And, of course, LSM303AH does not answer. What can be reason of it? Connection in principle and software are very similar I suppose.

    Visitor II
    December 29, 2019

    Strange, SCK is an input to all slaves and should be a push pull output from the microcontroller.

    Did you make sure the level shifter you use is for bidirectional lines?

    Also make sure you MCU pins are not open-drain (if the pins of the micro is for I2C and SPI, there maybe issue also there).

    Visitor II
    December 29, 2019

    Please forget to level shifter - it was only example for LSM9DS1 - I could verify properly working communication of 3-wire SPI. It is on second PCI. Now I am working ( MCU and LSM303AH ) on 1,8V of course. I tried to play with settings of output pin topology of MCU connected to clock, but without succes. After problem with level pulled down I let only one LSM303AH connected to MCU (clock and data) and result is the same - clock of 0,9V level. Strange. I would like order LSM303AH kit to try to find problem - it will be easier to play with MCU and not destroy complicated PCB.

    Visitor II
    December 29, 2019

    For the SCK pin of the micro to be push pull low, check voltage, high and check voltage, input and check voltage.

    Could it be one of the device is not powered properly and the protection diods on the pin shows a lower voltage?

    Visitor II
    December 29, 2019

    But data output to SDI_SDO from MCU is working properly, I think it is similar case to SCK.

    Visitor II
    January 5, 2020

    Regarding of PCB design it was very complicated to find solution. Now, after replacing of one bad device on the bus everything works well as should and level on SCK is 1,8V. Thank you for your support.