cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I am using LIS3DH in one of the application. What will happen if you read the registers second time after writing the registers? I am reading the registers with I2C multiple bytes, updating only the required bits and writing registers.

UMahi.1
Associate II

 am reading the registers with I2C multiple bytes, updating only the required bits and writing registers. So without power reset if i follow same sequence of reading again and updating only bit values (but writing full register values) then the output value stucks at one reading always. So if what will happen if we read all the registers second time without power off?

4 REPLIES 4
Eleon BORLINI
ST Employee

Hi @UMahi.1​ ,

If you write a register (or multiple registers) and then you read back the same register (or multiple registers), and you find that the registers' content is the same, there is no issue. Of course, you can only do it with readable/writable registers such as -for example- the control registers (CTRL_REG1...), and not the output registers (read only), or the factory-calibrated registers (whose value has not to be changed). If you write the single bits, it is better to mask the other bits not to overwrite the data.

If you power off the device, then the registers' content reset to the factory value, since the memory is volatile. In this case you have to rewrite the values when you reboot the device.

You say that the output is stuck after 1 value: are you working in FIFO mode, or are you maybe doing wrong with multiple-bit I2C reading?

I suggest you to check the C driver examples on Github for the LIS3DH device, especially the lis3dh_read_data_polling.c and the lis3dh_multi_read_fifo.c sample codes.

-Eleon

Thank you Eleon.

I am not using FIFO mode and using bypass mode. My observation is during runtime if I read second time the registers , value of FIFO control register becomes 0x19 from 0x00. Is there any impact to these registers ? Also, second question is related to power down mode. If we set odr bits to 0x00 then it goes to power down mode. But it is advisable to bring the device to power down mode by this method? Once we set these bits , again if we set odr bits to required data rate it will switch to normal mode?

UMahi.1
Associate II

Also, Can I know more about power down mode? I mean when we write ODR reg as 00 then it will go in power down mode but in power down mode any interrupt will be working or to wakeup from power down do we need to reconfig all registers again?

Hi @UMahi.1​ ,

About the power down mode, please consider this statement from the LIS3DH AN3308 application note, p.10

When the device is in power-down mode, almost all internal blocks of the device are switched off to minimize power consumption. Digital interfaces (I2C and SPI) are still active to allow communication with the device. The content of the configuration registers is preserved and output data registers are not updated, therefore keeping the last data sampled in memory before going into power-down mode.

>> But it is advisable to bring the device to power down mode by this method? Once we set these bits , again if we set odr bits to required data rate it will switch to normal mode?

A good procedure for switching modes is the following one:

4. Write 00h into CTRL_REG1 // Power down
5. Read REFERENCE // Reset filter block
6. Write 57h into CTRL_REG2 // Enable all axes // ODR = 100 Hz
7. Wait the duration of the turn-on time

>> do we need to reconfig all registers again?

no, it is not necessary if you don't power off the device.

-Eleon