2019-04-04 11:06 PM
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.
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);
Solved! Go to Solution.
2019-04-08 03:37 AM
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?
2019-04-08 03:37 AM
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?
2019-04-08 10:07 PM
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.
2019-04-08 11:58 PM
you're welcome