I'm trying to interface LSM303CTR e-compass from ST-microelectronics with microcontroler. Due to design limitations I have to use 4-wire SPI.

This MEMS device has option to switch beetween 3-wire SPI/I2C by using ChipSelect pin (which I personally think is an absurd).

When CS is low - SPI is active, I2C is endisabled and chip is selected When CS is high - SPI is disabled, but I2C is enable

Here lies the problem. It I unselected chip by pulling CS high, I also enable I2C transceiver in MEMS device. But my MEMS sensor is connected to same bus with other devices. I have other devices on same bus (SD memory, LCD). I don't want to interfere with transmission from SD and LCD.

So here are my questions:

  1. How to safely interface 3-wire SPI with 4-wire SPI
  2. How mentioned I2C transceiver in MEMS device could interfere with my SPI bus while CS is high-state.
  • \$\begingroup\$ Welcome to EE.SE. I recomend adding a link to the MEMS-device's datasheet in question. \$\endgroup\$ – Ariser - reinstate Monica Oct 6 '19 at 14:09

So you will have a circuit like this, where M1 is your 4-wire device and U2 is 3-wire device:

enter image description here

When accessing 3-wire device, you need to send and receive data on the same pin (MOSI). How to achieve this, depends on your MCU. When 3-wire device is sending data, other devices on the bus are not selected, so there's no issue.

According to the datasheet of LSM303CTR, I2C block can be disabled by software.

In order to disable the I2C block for the accelerometer, CTRL_REG4_A (I2C_DISABLE) must be written to ‘1’, while for magnetometer CTRL_REG3_M (I2C_DISABLE) must be written to ‘1’.

| improve this answer | |
  • \$\begingroup\$ Thank you! That fully solves my problem. Solution with disabling MEMS's I2C is great idea. I'm using stm32 so the tri-state operation of MOSI shouldn't be a problem. \$\endgroup\$ – Felix Oct 6 '19 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.