Skip to main content
Visitor II
August 21, 2022
Solved

Algoritm reading FIFO LIS3DH

  • August 21, 2022
  • 2 replies
  • 1055 views

In my project, I used the LIS3DH chip. Most of the time the processor sleeps.

The processor wakes up on time and on exceeding the shock threshold.

In case of awakening on shock threshold, I need to read the data from the FIFO buffer (32 measurements) that were before the wake-up signal

and a series of measurements (600-32) after waking up.

How could I do this?

Now I am reading the measurements while waiting for the ZYXDA register ready bit STATUS_REG(27h) set. FIFO always enabled in Stream mode.

But this metod may not work when reading the FIFO part of the measurements. Should I change the read algorithm when reading data from FIFO?

I think this is the algorithm:

1. Read FIFO 32 measurements on wakeup by observing the EMPTY bit of the FIFO_SRC_REG(2Fh) register

2. Disable FIFO by resetting FIFO_EN register CTRL_REG5(24h)

3. Read 600 - 32 measurements waiting for ZYXDA bit STATUS_REG(27h)

Or is it possible somehow easier?

In the DocID17530 Rev 2 and AN3308 documentation, I did not find an answer to the question of how the ZYXDA bit of the STATUS_REG (27h) register behaves when reading FIFO

    This topic has been closed for replies.
    Best answer by MegaVolt

    Thanks for the answer. Yes, the example reads the FIFO level and then reading the same number of measurements. In my opinion, I did it easier - I read FIFO before setting the FIFO EMPTY bit to really bit (�? does not participate in the exchange with FIFO. And in fact, bit ZYXDA does not participate in the exchange with FIFO.

    2 replies

    ST Employee
    August 23, 2022

    Hi @MegaVolt​ ,

    I believe the described algorithm could be correct. The STATUS_REG(27h) is described in the datasheet p.39, the ZYXDA is basically the data ready flag.

    0693W00000QOKICQA5.pngI also suggest you to check the C code on Github --> lis3dh_multi_read_fifo.c

    -Eleon

    MegaVoltAuthorAnswer
    Visitor II
    August 23, 2022

    Thanks for the answer. Yes, the example reads the FIFO level and then reading the same number of measurements. In my opinion, I did it easier - I read FIFO before setting the FIFO EMPTY bit to really bit (�? does not participate in the exchange with FIFO. And in fact, bit ZYXDA does not participate in the exchange with FIFO.