LSM6DS3 FIFO Status/FTH for Continuous to FIFO
I am trying to configure a LSM6DS3 to capture Tap events in the FIFO similar to how Unico does.
i.e. I press "Continuous to FIFO" button (to enable a new capture), then tap the sensor, and the acceleration of the tap event appears on the screen (after being read from the FIFO).
I used Unico to derive my configuration. It is here in csv format:
Addr,Name,Value (hex), comment
10,CTRL1_XL,60,ORD==416Hz
06,FIFO_CTRL1,60,FIFO Threshold, FTH == 96 words, 32 samples, 3 (x,y,z) axis
07,FIFO_CTRL2,00,
08,FIFO_CTRL3,01,accelerometer, no decimation
09,FIFO_CTRL4,00,
0A,FIFO_CTRL5,33,FIFO ODR==416Hz, Continuous-to-FIFO
5F,MD2_CFG,40,Note: AN5040 - Rev 3 "8.2.4 Continuous-to-FIFO mode", "Single tap: event detection has to be configured and the INT2_SINGLE_TAP bit of the MD2_CFG register has to be set to 1;"
13,CTRL4_C,00, STOP_ON_FTH==0 (configuration A)
13,CTRL4_C,01, STOP_ON_FTH==1 (configuration B)
With this configuration I expect that the FIFO will contain:
* 32 accelerometer samples for each axis
* contain the Tap Event
* the timeframe immediately before the Tap Event.
I tried two different configurations (A and B)to achieve this by changing CTRL4_C, STOP_ON_FTH.
Note: I know that the Tap Event is working because I rout it to INT1, and use this to trigger the FIFO read.
---------------------------------------
Test 1, Configuration A (STOP_ON_FTH==0)
In configuration A, I think the FIFO is filling beyond the FTH. When I read the first FTH the data doesn't contain the tap event as if the FIFO is longer than FTH.
When I read FIFO status I see:
Addr,Name,Value (hex), comment
3A,FIFO_STATUS1,00,DIFF_FIFO_[7:0]
3B,FIFO_STATUS2,E0,DIFF_FIFO_[11:8], FTH == 1, FIFO_OVER_RUN == 1,FIFO_FULL == 1,FIFO_EMPTY == 0
Why is this indicating there are 0 unread bytes?
---------------------------------------
Test 2, Configuration B (STOP_ON_FTH==0)
In configuration B, I think the FIFO is filling as soon as it is enabled, and then stopping upon sample STOP_ON_FTH. Obviously, this will not capture the Tap Event.
When I read FIFO status I see:
Addr,Name,Value (hex), comment
3A,FIFO_STATUS1,60,DIFF_FIFO_[7:0]
3B,FIFO_STATUS2,E0,DIFF_FIFO_[11:8], FTH == 1, FIFO_OVER_RUN == 1,FIFO_FULL == 1,FIFO_EMPTY == 0
I think FIFO_STATUS values make sense, but as described above the Tap Event isn't contained in the 0x60 words read.
---------------------------------------
It is difficult to decipher if Continuous-to-FIFO mode ever triggering FIFO mode to capture the Tap Event, or is the data I read the Streaming/Continuous (current) acceleration.
Why would Configuration A cause 0 unread bytes?
Is STOP_ON_FTH causing the FIFO to stop capturing new data as soon as Continuous-to-FIFO and 32 words are read?
Is the behavior I want possible? Can I limit the number of FIFO bytes to read in Continuous-to-FIFO mode by setting FTH?
