Skip to main content
Visitor II
July 3, 2018
Question

LSM6DS3 Continuous FIFO interrupts

  • July 3, 2018
  • 1 reply
  • 791 views
Posted on July 03, 2018 at 03:35

LSM6DS3 Continuous FIFO interrupts

For this discussion 1 sample = 6 bytes of 3d accelerometer data.

I want to use FIFO to save power on CPU.

As long as all sample data fits in the FIFO, all is straight-forward.

I'm unable to figure out how to use Continuous mode to read more samples

than fit in the FIFO.

Example:

I want's to read 2048 samples x 6 bytes.

Because FIFO is 8k I intend to read 2 x 1024 samples. I have tried many combinations

of fifo status bits, but no approach works. Here's one attempt:

setup

-----

FIFO_CTRL3.DEC_FIFO_XL = 1

CTRL4.DRDY_MASK = 1

FIFO_CTRL1/2.FTH = 3093 // (1024 samples + 7 discards (my setting)) *3

INT1_CTRL.INT1_FTH = 1

FIFO_CTRL5.FIFO_MODE = 6 // Continuous mode

isr

---

if (FIFO_STATUS2.FIFO_FULL == 0)

   // first read

   // discard initial samples

   // read first 1024 samples

   // next watermark = 1024 - (MAX_FIFO - already read). I usually get 1031 samples in first round,

   // so 1024 - ( 4095/3 - (1031 ) = 1024 - (1365 - 1031) = 1024 - 334 = 690. 690 * 3 = 2070

   FIFO_CTRL1/2.FTH = 2070

   INT1_CTRL.INT1_FTH = 0

   INT1_CTRL.INT1_FULL_FLAG = 1 // This status bit never gets set when isr is called again

   CTRL4.STOP_ON_FTH = 1 // should set full bit but doesn't. Only FTH bit set.

   TAP_CFG.LIR = 1 // makes no difference

else

   // last read.

   // Read ending 1024 samples and shut down XL

   // note! 'else' code never executes because FIFO_FULL status never gets set

result

----

1st interrupt

FIFO_STATUS1/2.DIFF_FIFO == 3093 // correct

FIFO_STATUS2.FTH == 1 // correct

FIFO_STATUS2.FIFO_FULL == 0 // correct

2nd interrupt

FIFO_STATUS1/2.DIFF_FIFO == 2068 // WRONG

FIFO_STATUS2.FTH == 1 // correct

FIFO_STATUS2.FIFO_FULL == 0 // WRONG

---

Why am I not seeing expected FIFO_FULL flag and what should I change.

Please feel free to suggest another method altogether!
    This topic has been closed for replies.

    1 reply

    Graduate II
    August 10, 2018

    Sorry, bumping old zombie unanswered questions off my feed