cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect more LSM303AH on one SPI BUS?

PUnze.1720
Associate II

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?

10 REPLIES 10
Eleon BORLINI
ST Employee

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

PUnze.1720
Associate II

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?

Eleon BORLINI
ST Employee

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

PUnze.1720
Associate II

Thank you for fast reply!

PUnze.1720
Associate II

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.

S.Ma
Principal

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).

PUnze.1720
Associate II

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.

S.Ma
Principal

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?

PUnze.1720
Associate II

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