cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3DH I2C ADDRESS AUTO INCREASE FOR FIFO

mehmetcanbalci
Associate III

I believe there is a unclear statement about FIFO address auto inreasement and 8-bit sub address issue;

here is two explanation from the datasheet;

8bit sub address auto inrease : (page 25 6.1.1 I2C operation)

... 7 LSb represent the actual register address while the MSB enables address auto increment. If the MSb of the SUB field is ‘1’, the SUB (register address) is automatically increased to allow multiple data read/writes...

5.1.5 Retrieving data from FIFO (page 23)

...The address to be read is automatically updated by the device and it rolls back to 0x28 when register 0x2D is reached. In order to read all FIFO levels in a multiple byte read, 192 bytes (6 output registers of 32 levels) have to be read....

Can we say if we read start to read by 0x28 it will automatically rollback once it reaches to 0x2d , but i dont see any info what will happen if i will set the 8th bit of the 0X28 address ?

So what will happen and how it will behave if i will start reading 0xA8 (0x28 | 0x80) ? it will just auto increase until 0xFF or it will rollback once it will reach to 0x2d ?

Best regards.

5 REPLIES 5
niccolò
ST Employee

Hi @mehmetcanbalci​ ,

when accessing the FIFO, you should perform the read as the datasheet says, otherwise the outcome of the operation can be wrong and data can be lost in the process.

Do you want to read all registers at once?

Hi ,

i want to read all the registers at once , but as i mentioned above two given information at the different pages of the datasheet makes it unclear.

what will happen and how does it behave if i will start reading 0xA8 (0x28 | 0x80) ,because this is legal according to (page 25 6.1.1 I2C operation)?

What is your comment about my first question , because i give two different information from the datasheet.

i am talking about these two info ,and i need answer what will happen when i read address 0xA8 (msb=1 of 0x28 ); (i already gave the page numbers and sections regarding these two info)

... 7 LSb represent the actual register address while the MSB enables address auto increment. If the MSb of the SUB field is ‘1’, the SUB (register address) is automatically increased to allow multiple data read/writes...

...The address to be read is automatically updated by the device and it rolls back to 0x28 when register 0x2D is reached. In order to read all FIFO levels in a multiple byte read, 192 bytes (6 output registers of 32 levels) have to be read....

Hi @mehmetcanbalci​  ,

You are right, the datasheet does not explain that in detail.

I think that if you read the register  OUT_X_L (28h) setting the MSB of SUB to 1 you will read all the FIFO, while setting the MSB of SUB to 0 you just read the first register.

I don't have access to a LIS3DH right now, but I can have it delivered and I can develop a firmware to test the two situations, I think that in a few weeks I can give you a response.

If you already have the sensor and the firmware, maybe you can try it and share your results.

I just did not understood whether you want to

  • read all the sensor registers to check the configuration parameters (in this case you could also do a read until the register 28h and then a read from the 2Eh to complete all registers)
  • read all the FIFO (you should read 192 bytes from 28h putting the MSB of SUB to 1)

Hi Niccolo ,

Thank you for your response , i am looking forward seeing your results , indeed i will try myself right now .

I want to read all the available FIFO data and STATUS_REG(0x27) in once. When i got the FIFO full interrupt , i am gonna start i2c transaction from the address 0xA7 ( MSB1 STATUS_REG(0x27) to auto increase ) then i will read 192+1 =193 bytes . So according to my understanding/desire i will get STATUS_REG+all the 192 bytes fifo data.

Hi @mehmetcanbalci​ ,

were you able to read all data according to your goal?