cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DW12 FIFO overflows upon wake-up by interrupt

ZAIDS-S23
Associate III

Greetings

I have configured  the LIS2DW12, via SPI,  to sample and store samples, given the FIFO (configured in continuous mode) on a wakeup interrupt to INT1. The sensor, given its current configuration is able to wake up and sample but there is a worrying issue where, on the first wake-up (providing some movement to the sensor),  the FIFO always overflows. I am seeing this when my ISR fires and the data-read-function is called, and within the read function, I am checking for the overflow and then essentially returning an error. If I try waking it up again, it samples fine without overflow occurring.

Any help would be appreciated to figure out why overflow occurs ONLY on the first wake-up.

My current configuration is:

Write(CTRL2 , 0X1E)        //BDU ENABLED, I2C Disabled, IF_ADD_INC EN, Disable CS_PU
Write(CTRL6 , 0X10)        //enable HPF, ODR/2, FS = 2G
Write(WAKE_UP_THS , 0X0C)  //Threshold = 375mg
Write(WAKE_UP_DUR , 0X00)  //No-wakeup time
Write(FIFO_CTRL , 0XC0)    //continuous mode
Write(CTRL4_INT1 , 0X20)   //route Wakeup event to INT1

Write(CTRL1 , 0X50)        //Low-power mode 1, ODR = 100Hz
delay(20ms)                //settling time
Write(CTRL7 , 0X20)  

/********START ISR*****/
Read(FIFO_SAMPLES_REG)          //Check overflow bit here
if(overflow bit is set in FIFO_SAMPLES_REG) 
{
 Write(FIFO_CTRL , 0X00) //clear fifo
 Write(FIFO_CTRL , 0XC0) //set to continuous mode

}

else
{
  Read(OUT_X_L, 6)           //Read the 6 output registers
  x = data[1], data[0]
  y = data[3], data[2]
  z = data[5], data[4]
}
Write(FIFO_CTRL , 0X00) //clear fifo
Write(FIFO_CTRL , 0XC0) //set to continuous mode

/**********END ISR******/

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Federica Bossi 

I believe I have found the solution to my problem, which also shows I did not do the right things but nevertheless, it can stop someone else from making the same mistakes.

To address the issue of the FIFO overflow, I believe this CANNOT be avoided if the device is in continuous mode from the point of initialisation, to the point where one would read the data from the data registers. Since it is always filling the FIFO buffer, it will always be full of samples and overwrite itself. 

The prescribed method to read on an interrupt should be bypass-to-continuous. Continuous should never be used unless one wants to sample at a specific point in time, for a specific amount of time, independent of an interrupt. Otherwise, bypass-to-continuous prevents any overflow, as you can read the data registers in the INT1_FTH interrupt's ISR, until you don't want to.

View solution in original post

4 REPLIES 4
ZAIDS-S23
Associate III

@Federica Bossi @Eleon BORLINI I believe you guys can help me here, if not anyone else. Apologies, I forgot to use the initial function to @ you, when I created the post. 

Federica Bossi
ST Employee

Hi @ZAIDS-S23 ,

Have you already look at our examples on Github?

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Federica

Yes, I have looked at those examples. I am, more or less, adapting whatever I can from the examples but my application is different. There are 2 examples that pertain to me, the "read FIFO" and "wake up", however the wake-up example just enables the interrupt and will tell the user what axes caused the wake up. The fifo example polls the watermark of the fifo_samples register.

I am trying to sample upon the accelerometer being woken up, where the very first time of the device sampling, causes an overflow in the fifo_samples register. 

Hi @Federica Bossi 

I believe I have found the solution to my problem, which also shows I did not do the right things but nevertheless, it can stop someone else from making the same mistakes.

To address the issue of the FIFO overflow, I believe this CANNOT be avoided if the device is in continuous mode from the point of initialisation, to the point where one would read the data from the data registers. Since it is always filling the FIFO buffer, it will always be full of samples and overwrite itself. 

The prescribed method to read on an interrupt should be bypass-to-continuous. Continuous should never be used unless one wants to sample at a specific point in time, for a specific amount of time, independent of an interrupt. Otherwise, bypass-to-continuous prevents any overflow, as you can read the data registers in the INT1_FTH interrupt's ISR, until you don't want to.