Showing results for 
Search instead for 
Did you mean: 

ism330dlc:ctrl1_xl(10h) value is overwritten every time when tring to read other registers

Associate II

My board is having the accelerometer device ism330dlc. I am trying to write the value 0x4a to CTRL1_XL(10h).

I am using the default  accelerometer driver :

I set the sampling frequency to 104000 and then I write the value 0xa to CTRL1_XL. When I check the i2cdump, I can see that the value of register 10h is set to 4a. But when I try to read the values of in_accel_x_raw, in_accel_y_raw, in_accel_z_raw , I can see the value of CTRL1_XL(10h) is getting overwritten. Could you please let me know how can I keep the value of CTRL1_XL constant without being overwritten when trying to access other register values?

ST Employee

Hi @smoha.2 ,

first of all, can I ask you if you are able to correctly read the WHO_AM_I (0Fh) register ?
this is just to confirm that the read values are right.

if the value read is correct, try to read the CTRL1 (10h) register right after you write it, to confirm it was written (I think that the i2c dump is checked with an oscilloscope, if it's not that, please, let me know how you check the operation)

lastly, I don't really understand if you see some data and then you read again the CTRL1, or you read everything together.

also, keep in mind that you are setting the ODR (Output Data Rate) to 104 Hz, not 104000 Hz, as you stated


Associate II

Hello Niccolo,

Thanks for your reply.

I am trying to read the register values using the i2cdump utility(i2c-tool) and I can confirm the value of WHOAMI register is correct(0x6a). So what is happening is that if I update the value of CTRL1_XL using the sysfs entries, I can see the value is getting written. But when I try to read any of the values from in_accel_x_raw, in_accel_y_raw, in_accel_z_raw, the value of CTRL1_XL is getting overwritten. This is happening when the function st_lsm6dsx_read_oneshot gets involved.

The frequency is 104Hz only

Hi @smoha.2 ,

can you try to read with the st_lsm6dsx_check_odr the odr before and after the read?