2018-03-09 02:44 AM
The LIS3DH is configured to use INT1 to interrupt the MCU when the acceleration value on any of the 3 axis exceed the threshold that is set by the MCU. Firstly, as my understanding, the LID3DH does not stop sampling acceleration data even if the interrupt is triggered (even in stream-to-fifo mode, it does not stop sampling until the fifo gets full). Is this correct? If it's correct, is there a good way to get the acceleration data corresponds to the exact time when the interrupt is triggered? Thanks.
Solved! Go to Solution.
2018-03-12 07:12 AM
You understanding is correct and the stream-to-fifo mode is exactly the right mode for the purpose.
FIFO content will be composed of #30 samples collected before the trigger event, the sample that has generated the interrupt event and one sample after the trigger.
Please check chapter 9.3.4 in the application note
.2018-03-12 07:12 AM
You understanding is correct and the stream-to-fifo mode is exactly the right mode for the purpose.
FIFO content will be composed of #30 samples collected before the trigger event, the sample that has generated the interrupt event and one sample after the trigger.
Please check chapter 9.3.4 in the application note
.2018-03-13 01:40 AM
Thanks for the reply. My understanding is a bit different. In AN3308, it describes following about the stream-to-fifo mode:
So as my understanding, if the case 2 happens, we are still not able to know where in the fifo the trigger data is. Right?
So do I have to read back all the 32 data sample in the fifo and compare to the Threshold I set? The first sample in the fifo that exceed the threshold is the trigger data.
2018-03-15 09:43 AM
You are right, in case 2 you want be sure which sample corresponds to the interrupt and you have to compare each sample with threshold. But this case can happen only when you start your measurement, after 32 samples the FIFO will be full and case 1 will happen.
2018-03-16 12:59 AM
Thanks for the reply. So case 2 just happens once in the initial state. Most cases it's case 1.
As AN3308 describes, when the fifo is full, it stop collecting data at first sample after the trigger, so the data that trigger the interrupt should be at F[30]. But when I read out the 32 data from lis3de when the MCU is interrupted (the fifo should be full at this time because I wait for enough time) and compare the data with the threshold, it turns out the trigger data is always at F[26]. Why? I'm using lis3de as the sensor.
2018-03-16 03:30 AM
What is your DURATION settings for the interrupt?
This could explain why the trigger was reached already at FIFO sample 26, but the interrupt was triggered after DURATION number of samples exceed the threshold.
2018-03-16 04:42 AM
My duration is 5. Now I completely understand. Thank you very much.
2018-03-19 09:08 PM
One more question: What if the duration setting is larger than 31? My assumption is the fifo will contain the last 31 samples of the trigger data and 1 samples of the sample after the trigger. Am I right?
2018-03-20 02:53 AM
Yes, you are right.
2018-03-20 04:37 AM
More question pops up. A typical use case for Stream-to-Fifo mode is to flush the fifo by setting it to bypass mode and set it back to Stream-to-Fifo mode. If we do not do this, the fifo will be kept full and can no longer store data. This operation will happen frequently during the measurements. If the trigger comes quick enough after the fifo is flushed, case 2 will happen. So case 2 is not that rare and we should not treat case 2 as a special case. Am I right?