2024-01-02 11:29 PM - edited 2024-01-02 11:37 PM
Greetings
I am working with the LIS2DW12 accelerometer and I am struggling to read from, and use the FIFO in single-conversion mode, using i2c. The chip is on a dev board which can only be used with i2c, and the INT1 or INT2 pins are not available for use.
I am configuring the chip in low-power 12-bit mode, with an ODR of 50Hz.
My configuration function:
write(CTRL2_REG, 0x0C) //block data update = 1, device-addr increment = 1
write(CTRL6_REG, 0x00) // filter = ODR/2
write(FIFO_CTRL_REG, 0x20) //fifo mode
write(CTRL1_REG, 0x48) // low-power 12-bit mode, with an ODR of 50Hz, single-conversion mode
write(CTRL7_REG, 0x20) //enable interrupts
To run the chip in single-conversion mode and read from the fifo, the function I have written is as follows:
write(CTRL3_REG, 0x02) //enable start-of-single-conversion by I2C
write(CTRL3_REG, 0x03) // start measurement
After this. I am confused, as I have posted previously
When I try to read the number of unread samples in the FIFO_Samples register, I continuously get zero. Thus, I do not have a clear indicator of when I need to read from the output registers. I can verify the read functionality as well, as I check the WhoAMI everytime the chip boots up and that checks out. I have also added a delay after the last write command to CTRL3, to ensure the FIFO can fill up according to the clock cycles required (32 cycles * 1/50 = 640ms delay).
My attempt to read from the FIFO_Samples register, where ui8Data is zero:
read(FIFO_Samples_reg, ui8Data);
ui8Data &= 0x3F;
Please can I have some help on this.
Regards
2024-01-03 01:42 AM
Hi @ZAIDS-S23 ,
After setting the accelerometer configurations, I suggest you to read samples in polling mode (without interrupt) and read the acceleration output only if new value is available (check the fifo_wtm_flag).
You can follow the steps in this PID example.
Let me know if you solve.
2024-02-01 12:38 AM
Hi @ZAIDS-S23 ,
Has my answer helped you?
2024-02-01 12:43 AM
Hi @Federica Bossi,
Unfortunately not. I did not get the FIFO working as it should (able to actively monitor its state or count the no. of samples), using polling methods. I've found hardware that has the chip's interrupt pins routed and that worked instantly. I am able to receive interrupts on the state of the FIFO and monitor the no. of samples.
I am not sure why it doesn't work with polling techniques. All I did from the original configuration was use the interrupt pins for the FIFO_FTH flag and configure the WK_UP_THS register for a wakeup of 375mg or so, to get it working as it is now. So in terms of the FIFO, there's nothing that was changed and nothing I haven't tried, when I was attempting to poll the FTH flag.