2018-03-08 03:18 PM
Hey! I am using the accelerometer LSM303AGR to read some acceleration values on external interrupt. If the threshold is overcome, and interrupt will be triggered and in the ISR, I am reading the FIFO of the accelerometer (I am using STM32F405 btw). The values seem to be correct half of the time as shown below. As you can see in the third interrupt and fifo reading, the zAxis exceeded the threshold and then, out of nowhere, the axis-values are getting weird (and wrong!). They won't return back to normal and therefore, no more interrupts are triggered. If I stop, reset and run it again, no interrupts can be triggered because the values are still weird and wrong. The only thing that helps is to cut the power supply for a second and plug it in again. But even that does not help sometimes.
readINT1_SRC: 86
FIFO samples: xAxis exceeds thresholdx: 3189.199951 y: -375.200012 z: 750.400024 x: 3564.399902 y: -187.600006 z: 1125.599976 x: 3189.199951 y: -187.600006 z: 1125.599976 x: 2251.199951 y: 0.000000 z: 1125.599976 x: 0.000000 y: -187.600006 z: 1125.599976 x: -2063.600098 y: 375.200012 z: 750.400024 x: -2814.000000 y: 562.799988 z: 750.400024 x: -3752.000000 y: 375.200012 z: 938.000000 x: -2626.399902 y: 562.799988 z: 938.000000 x: -1313.199951 y: 562.799988 z: 938.000000 x: -562.799988 y: 0.000000 z: 938.000000 x: -562.799988 y: 187.600006 z: 938.000000 x: -562.799988 y: 0.000000 z: 938.000000 x: -187.600006 y: 0.000000 z: 938.000000 x: 187.600006 y: 0.000000 z: 750.400024 x: 187.600006 y: 0.000000 z: 750.400024 x: 187.600006 y: 0.000000 z: 750.400024 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: -187.600006 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 187.600006 y: 0.000000 z: 938.000000 x: 187.600006 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 187.600006 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 x: 0.000000 y: 0.000000 z: 938.000000 readINT1_SRC: 101FIFO samples: zAxis exceeds thresholdx: 1125.599976 y: 562.799988 z: 3564.399902 x: 187.600006 y: 938.000000 z: 4690.000000 x: -750.400024 y: 750.400024 z: 5252.799805 x: -1688.400024 y: 375.200012 z: 0.000000 x: 469.000000 y: 0.000000 z: 562.799988 x: -187.600006 y: 0.000000 z: 140.699997 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 x: 0.000000 y: 140.699997 z: -187.600006 readINT1_SRC: 86FIFO samples: xAxis exceeds thresholdx: -3189.199951 y: 562.799988 z: 938.000000 x: 0.000000 y: -938.000000 z: 0.000000 x: -2720.199951 y: 375.200012 z: 1125.599976 x: 0.000000 y: -938.000000 z: 0.000000 x: 0.000000 y: -938.000000 z: 0.000000 x: -375.200012 y: -4127.200195 z: 2438.800049 x: -375.200012 y: -4314.799805 z: 2532.600098 x: -375.200012 y: -4314.799805 z: 2532.600098 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -375.200012 y: -4127.200195 z: 2438.800049 x: -375.200012 y: -4314.799805 z: 2532.600098 x: -375.200012 y: -4314.799805 z: 2532.600098 x: -375.200012 y: -4314.799805 z: 2532.600098 x: -375.200012 y: -4127.200195 z: 2532.600098 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -375.200012 y: -4314.799805 z: 2438.800049 x: -375.200012 y: -4314.799805 z: 2532.600098 x: -469.000000 y: -4127.200195 z: 2532.600098 x: -375.200012 y: -4314.799805 z: 2438.800049 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -281.399994 y: -4221.000000 z: 2532.600098 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -469.000000 y: -4221.000000 z: 2532.600098 x: -469.000000 y: -4221.000000 z: 2438.800049 x: -375.200012 y: -4221.000000 z: 2532.600098 x: -375.200012 y: -4221.000000 z: 2438.800049 x: -375.200012 y: -4127.200195 z: 2438.800049 x: -281.399994 y: -4314.799805 z: 2438.800049 x: -375.200012 y: -4221.000000 z: 2532.600098I have attached my code to this post. So you can see the code I have written. Maybe this will help for finding a solution.
I appreciate every advice and help you can give me, thank you in advance!
#accelerometer #external-interrupt #motion-sensor #lsm303agr #sensor-tile2018-03-12 09:07 AM
I don't know what is the root cause of this issue, but I see a few problems in your code.
I might help to fix it.
2018-03-19 08:57 AM
Batek.Miroslav
Hey Miroslav, thank you for your answer. I have also noticed the mistake of writing 0x0A to the 0x2E register, but if I write 0xC0 (which would correctly be the Stream-to-FIFO mode), the values of the accelerometer are also more than wrong and seem to be stuck. Two your second point: Why do I have to check for the actual number of samples stored in the FIFO? I thought if a interrupt takes place, the mode will switch to FIFO-mode and the FIFO will be filled until its full. So in the end, I will always have 32 valuesstored in the FIFO?Thank you in advance for your help!