cancel
Showing results for 
Search instead for 
Did you mean: 

Best and quickest way to clear the LSM6DSL's FIFO when full.

David Kaplan_2
Associate II

We use the LSM6DSL chip's accelerometer without the gryo in FIFO mode 110b Continuous mode. (If the FIFO is full, the new sample overwrites the older one.) Every fixed period I read the FIFO1 & FIFO2 status bytes and read the number of unread words (BDU bit in CTRL3_C (12h) to 1). Rarely I read a fifo status word value of 0xE000. Watermark,Overrun,smart full bits are raised but the number of words not read is zero. When this happens I need to reset our last periodic check which reads samples for a specific number of seconds and no overruns can be tolerated. The FIFO full state happens rarely and sometimes I have not been able to clear this situation. How should I clear the FIFO starting my sampling over, the best and quickest way?

2 REPLIES 2
Eleon BORLINI
ST Employee

Hi @Community member​ , I'm not sure I exactly caught your point. If you want to be sure the FIFO gets full, you should work in pure FIFO mode, as explained in the AN5040 p.82:

When the next stored set of data will make the FIFO full, the FIFO_FULL_SMART bit of the FIFO_STATUS2 register is set to 1 and no more data are stored in the FIFO buffer. Data can be retrieved after the FIFO_FULL_SMART event by reading the FIFO_DATA_OUT_L and FIFO_DATA_OUT_H registers for the number of times specified by the DIFF_FIFO_[10:0] bits of the FIFO_STATUS1 and FIFO_STATUS2 registers.

If you work in Continuous mode, try to set maximum threshold and activate STOP_ON_FTH bit, to not incur in overrun issues.

Regards

David Kaplan_2
Associate II

No, exactly the opposite, I want to be sure that the FIFO does NOT get full and if it does by some reason, I have to restart my accumulating process. I continuously read the FIFO status emptying the FIFO till I accumulate a specific number of X,Y & Z samples (2048). I have to read consecutive samples without any overflows that would mean missed data.

In a perfect situation FIFO overflow should never happen but my main loop may rarely take longer and overflows may happen. When the overflow happens, I get a FIFO status of 0xE000. 0xE000 is WaterM,OVER_RUN & FIFO_FULL_SMART flags raised but DIFF_FIFO = 0! I need to recover from this situation the fastest and easiest way and restart accumulating samples discarding all samples beforehand. I do not have the ability to turn the LSM6DSl chip's power off and back on. Currently I just try to read the FIFO till there is no more entries and start over. If this does not work, I abort the sampling by LSM6DSL_FIFO_CTRL5=0 & LSM6DSL_CTRL1_XL=0 till the next sample cycle which is usually every 15 minutes. Sometimes nothing seems to help as shown in the log below where the periodic cycle for reading 2048 samples is 5 minutes:

3-8 22:13 09/03/2020 05:13:01 | 08/03/2020 22:12:47[ami_LSM6DSL.c: 482] FF:0xE000 0 37

3-8 22:13 09/03/2020 05:13:01 | 08/03/2020 22:12:47[ami_log.c: 987] AquireOnly

3-8 22:18 09/03/2020 05:18:01 | 08/03/2020 22:17:47[ami_LSM6DSL.c: 482] FF:0xE000 0 1

3-8 22:18 09/03/2020 05:18:01 | 08/03/2020 22:17:47[ami_log.c: 987] AquireOnly

3-8 22:23 09/03/2020 05:23:01 | 08/03/2020 22:22:47[ami_LSM6DSL.c: 482] FF:0xE000 0 1

3-8 22:23 09/03/2020 05:23:01 | 08/03/2020 22:22:47[ami_log.c: 987] AquireOnly

3-8 22:28 09/03/2020 05:28:01 | 08/03/2020 22:27:47[ami_LSM6DSL.c: 482] FF:0xE000 0 37

3-8 22:28 09/03/2020 05:28:02 | 08/03/2020 22:27:47[ami_log.c: 987] AquireOnly

3-8 22:33 09/03/2020 05:33:01 | 08/03/2020 22:32:47[ami_LSM6DSL.c: 482] FF:0xE000 0 1

3-8 22:33 09/03/2020 05:33:01 | 08/03/2020 22:32:47[ami_log.c: 987] AquireOnly

3-8 22:38 09/03/2020 05:38:01 | 08/03/2020 22:37:47[ami_LSM6DSL.c: 482] FF:0xE000 0 1

3-8 22:38 09/03/2020 05:38:01 | 08/03/2020 22:37:47[ami_log.c: 987] AquireOnly

3-8 22:43 09/03/2020 05:43:01 | 08/03/2020 22:42:47[ami_LSM6DSL.c: 482] FF:0xE000 0 37

3-8 22:43 09/03/2020 05:43:01 | 08/03/2020 22:42:47[ami_log.c: 987] AquireOnly

3-8 22:48 09/03/2020 05:48:01 | 08/03/2020 22:47:47[ami_LSM6DSL.c: 482] FF:0xE000 0 1

3-8 22:48 09/03/2020 05:48:01 | 08/03/2020 22:47:47[ami_log.c: 987] AquireOnly

3-8 22:53 09/03/2020 05:53:01 | 08/03/2020 22:52:47[ami_LSM6DSL.c: 482] FF:0xE000 0 1

3-8 22:53 09/03/2020 05:53:01 | 08/03/2020 22:52:47[ami_log.c: 987] AquireOnly

3-8 22:58 09/03/2020 05:58:01 | 08/03/2020 22:57:47[ami_LSM6DSL.c: 482] FF:0xE000 0 37