cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot make accelerometer LIS2DU12 in Sensor.Tile Pro working ?

jea74
Associate III

Hello,

I cannot make the LIS2DU12 working in the Sensor.Tile module. I followed the instruction in the AN5648 but I get random values for X, Y, Z. At first, I'm trying to get the readings in normal continuous mode without FIFO.

I can connect the device, WHO_AM_I returns the correct 69 value, I read X, y, & Z registers when the DRDY bit is set but these values are not correct....

In attach my configureLIS2DU12 and getLIS2DU12 functions and the X, Y, & Z values I get via serial

Thanks, J.

1 ACCEPTED SOLUTION

Accepted Solutions
jea74
Associate III

I answer to myself... bit 5 (IF_ADD_INC) of CRTL1 register must be set = Register address is automatically incremented during a multiple-byte access with a serial interface. (0: disabled (default); 1: enabled), page 30 of the datasheet. As I read the X, Y & Z in one go (8 bytes) with one HAL_I2C_Mem_Read()

memAddress = ACCELEROMETER_LIS2DU12_OUT_X_L;
		i2cSize = 8;
		i2cData[0] = 0;  i2cData[1] = 0;  i2cData[2] = 0;  i2cData[3] = 0;  i2cData[4] = 0;  i2cData[5] = 0;  i2cData[6] = 0;  i2cData[7] = 0;  i2cData[8] = 0;
		ret = HAL_I2C_Mem_Read(hi2c_accelerometer, (devAddress<<1), memAddress, I2C_MEMADD_SIZE_8BIT, i2cData, i2cSize, HAL_MAX_DELAY);	// LIS2MDL GET X, Y ,Z

Now the X, Y, Z values look like something much more OK with the Sensor.Tile resting on a table

X=-54.7, Y=-18.5, Z=-985.8 [mg]
X=-56.6, Y=-15.6, Z=-972.1 [mg]
X=-59.5, Y=-18.5, Z=-974.0 [mg]
X=-53.7, Y=-16.6, Z=-976.0 [mg]
X=-53.7, Y=-17.6, Z=-976.0 [mg]
X=-52.7, Y=-16.6, Z=-975.0 [mg]
X=-53.7, Y=-16.6, Z=-974.0 [mg]
X=-53.7, Y=-11.7, Z=-977.0 [mg]
X=-53.7, Y=-9.8, Z=-976.0 [mg]
X=-58.6, Y=-16.6, Z=-973.1 [mg]
X=-57.6, Y=-15.6, Z=-974.0 [mg]
X=-52.7, Y=-15.6, Z=-976.0 [mg]
X=-55.6, Y=-11.7, Z=-972.1 [mg]
X=-54.7, Y=-10.7, Z=-975.0 [mg]
X=-56.6, Y=-14.6, Z=-977.0 [mg]
X=-54.7, Y=-12.7, Z=-970.1 [mg]
X=-53.7, Y=-15.6, Z=-975.0 [mg]
X=-58.6, Y=-13.7, Z=-970.1 [mg]
X=-59.5, Y=-12.7, Z=-973.1 [mg]
X=-55.6, Y=-16.6, Z=-972.1 [mg]
X=-54.7, Y=-12.7, Z=-970.1 [mg]
...

 

 

View solution in original post

1 REPLY 1
jea74
Associate III

I answer to myself... bit 5 (IF_ADD_INC) of CRTL1 register must be set = Register address is automatically incremented during a multiple-byte access with a serial interface. (0: disabled (default); 1: enabled), page 30 of the datasheet. As I read the X, Y & Z in one go (8 bytes) with one HAL_I2C_Mem_Read()

memAddress = ACCELEROMETER_LIS2DU12_OUT_X_L;
		i2cSize = 8;
		i2cData[0] = 0;  i2cData[1] = 0;  i2cData[2] = 0;  i2cData[3] = 0;  i2cData[4] = 0;  i2cData[5] = 0;  i2cData[6] = 0;  i2cData[7] = 0;  i2cData[8] = 0;
		ret = HAL_I2C_Mem_Read(hi2c_accelerometer, (devAddress<<1), memAddress, I2C_MEMADD_SIZE_8BIT, i2cData, i2cSize, HAL_MAX_DELAY);	// LIS2MDL GET X, Y ,Z

Now the X, Y, Z values look like something much more OK with the Sensor.Tile resting on a table

X=-54.7, Y=-18.5, Z=-985.8 [mg]
X=-56.6, Y=-15.6, Z=-972.1 [mg]
X=-59.5, Y=-18.5, Z=-974.0 [mg]
X=-53.7, Y=-16.6, Z=-976.0 [mg]
X=-53.7, Y=-17.6, Z=-976.0 [mg]
X=-52.7, Y=-16.6, Z=-975.0 [mg]
X=-53.7, Y=-16.6, Z=-974.0 [mg]
X=-53.7, Y=-11.7, Z=-977.0 [mg]
X=-53.7, Y=-9.8, Z=-976.0 [mg]
X=-58.6, Y=-16.6, Z=-973.1 [mg]
X=-57.6, Y=-15.6, Z=-974.0 [mg]
X=-52.7, Y=-15.6, Z=-976.0 [mg]
X=-55.6, Y=-11.7, Z=-972.1 [mg]
X=-54.7, Y=-10.7, Z=-975.0 [mg]
X=-56.6, Y=-14.6, Z=-977.0 [mg]
X=-54.7, Y=-12.7, Z=-970.1 [mg]
X=-53.7, Y=-15.6, Z=-975.0 [mg]
X=-58.6, Y=-13.7, Z=-970.1 [mg]
X=-59.5, Y=-12.7, Z=-973.1 [mg]
X=-55.6, Y=-16.6, Z=-972.1 [mg]
X=-54.7, Y=-12.7, Z=-970.1 [mg]
...