2018-07-02 06:35 PM
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 samplesthan 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 combinationsof fifo status bits, but no approach works. Here's one attempt:setup
-----FIFO_CTRL3.DEC_FIFO_XL = 1
CTRL4.DRDY_MASK = 1FIFO_CTRL1/2.FTH = 3093 // (1024 samples + 7 discards (my setting)) *3INT1_CTRL.INT1_FTH = 1FIFO_CTRL5.FIFO_MODE = 6 // Continuous modeisr
---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 differenceelse // last read. // Read ending 1024 samples and shut down XL // note! 'else' code never executes because FIFO_FULL status never gets setresult
----1st interruptFIFO_STATUS1/2.DIFF_FIFO == 3093 // correctFIFO_STATUS2.FTH == 1 // correctFIFO_STATUS2.FIFO_FULL == 0 // correct2nd interrupt
FIFO_STATUS1/2.DIFF_FIFO == 2068 // WRONGFIFO_STATUS2.FTH == 1 // correctFIFO_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!2018-08-09 10:30 PM
Sorry, bumping old zombie unanswered questions off my feed