Skip to main content
Min-Kyoung Kim
Associate III
April 5, 2019
Solved

LSM303AGR, Accelerometer Read Address cannot be auto-incremented.

  • April 5, 2019
  • 1 reply
  • 911 views

Hi, I'm using LSM303AGR.

I cannot read acceleromter 6bytes from 0x28 _ 0x2D.

It is read only 0x28 register 6 times.

I tried to read other register, 0x20 0x21, etc...

Likewise, It is read only first address register 6 times or several times.

I also checked MS bit (bit1). it is 1 of course.

BUT!

It works Magnetometer same way!

I can read 6 registers magnetometer data.

Below Configure values.

  1. ODR : 1001 (1.344kHz)
  2. LPen : normal mode
  3. Zen, Yen, Zen : 1
  4. BDU : 0
  5. BLE : 0
  6. FS : 10 (8g)
  7. HR : 1
  8. ST : 00
  9. SPI_ENABLE : 1 (3 wire)

Below, my configuration code and reading code

	Sensor_IO_SPI_CS_Enable(&SensorHandle[ACCEL]);
	valueTx = 0x29;	//8g(Sensitivity : 3.9 mG/LSB), HR mode, 3 wire
	Sensor_IO_SPI_Write(&SensorHandle[ACCEL],LSM303AGR_ACC_CTRL_REG4,&valueTx,1);
	Sensor_IO_SPI_CS_Disable(&SensorHandle[ACCEL]);
 
	Sensor_IO_SPI_CS_Enable(&SensorHandle[ACCEL]);
	valueTx = 0x97; //1.344kHz, no power down(12bit, divisor : 16), x,y,z enabled
	Sensor_IO_SPI_Write(&SensorHandle[ACCEL],LSM303AGR_ACC_CTRL_REG1,&valueTx,1);
	Sensor_IO_SPI_CS_Disable(&SensorHandle[ACCEL]);
	Sensor_IO_SPI_CS_Enable(ctx);
 Sensor_IO_SPI_Read(ctx,ctx->RegRX, raw_data_tmp.u8bit,6);
 Sensor_IO_SPI_CS_Disable(ctx);

This topic has been closed for replies.
Best answer by Eleon BORLINI

Hi, the configuration should be ok, and magnetometer and accelerometer SPI communication should behave in the same way. Also in case of the magnetometer the MS bit is =1? Is it possible for you to share the oscilloscope pattern?

1 reply

Eleon BORLINI
Eleon BORLINIBest answer
ST Employee
April 8, 2019

Hi, the configuration should be ok, and magnetometer and accelerometer SPI communication should behave in the same way. Also in case of the magnetometer the MS bit is =1? Is it possible for you to share the oscilloscope pattern?

Min-Kyoung Kim
Associate III
April 9, 2019

I didn't know that the acceleromter ​register address is 7 bits.

I didn't set the MS bit to =1.

When I compared MS bit between accel and mag, I got it thank for your comment.

Thank you.

Eleon BORLINI
ST Employee
April 9, 2019

​you're welcome