cancel
Showing results for 
Search instead for 
Did you mean: 

LSM303AGR SPI operation

ash thorpe
Associate II
Posted on March 01, 2018 at 11:24

Hi,

I am struggling with moving from the obsolete LSM303D sensor to the LSM303AGR sensor.

I had the LSM303D sensor working correctly in continuous mode with the STM32F1 processor using 4 wire SPI mode.

But I cannot get the 3 wire SPI interface to work correctly with either sensor.

Concentrating on the LSM303AGR sensor - Currently I have CS_XL and CS_MAG inputs commoned up and driven from a single output of the STM32F1 master device. I assume this is incorrect and the 2 slave select inputs are mutually exclusive in SPI mode?

I was hoping that the slave select (CS) was irrelevant as SPI 3 wire interface is more like I2C, but I assume the accelerometer and magnetometer are treated as separate SPI slave devices in the LSM303AGR?

I just realized that although all register addresses between the accelerometer and magnetometer are unique, the address for multiple reads are not unique;

 multiple read for XL start address = 0xE8 (0x28 | Read bit | multiple register read bit)

 multiple read for MAG start address = 0xE8 (0x68 | Read bit)

Hopefully someone can confirm this assumption while I modify the hardware. Plus I wanted to start a thread incase other issues arise.

Thanks in advance for your help

Ash

#lsm303agr
1 ACCEPTED SOLUTION

Accepted Solutions
Miroslav BATEK
ST Employee
Posted on March 01, 2018 at 11:50

Yes, you cannot connect the CS_XL and CS_MAG together if you want to use SPI interface.

The accelerometer and magnetometer are treated as separate SPI slave devices. 

View solution in original post

3 REPLIES 3
Miroslav BATEK
ST Employee
Posted on March 01, 2018 at 11:50

Yes, you cannot connect the CS_XL and CS_MAG together if you want to use SPI interface.

The accelerometer and magnetometer are treated as separate SPI slave devices. 

ash thorpe
Associate II
Posted on March 01, 2018 at 12:25

Okay. Thankyou Miroslav for the quick reply.

I just wanted to be sure there was no way around this, as our hardware team want to minimize the PCB changes to move to the new sensor at late stage of development. 

Aishwarya
Associate III

LIS2DTW12 I²C/SPI mode selection

I want to read LIS2DTW12 data using SPI which is also shared with another device, can I use the LIS2DTW12 CS pin as chip select and operate devices one by one.

because according to the LIS2DTW12 datasheet:

State of CS

1: SPI idle mode / I²C communication enabled;

0: SPI communication mode / I²C disabled

i.e if cs = 1 --> I2C Enabled, read/write operation on another device will disturb the LIS2DTW12 device.