cancel
Showing results for 
Search instead for 
Did you mean: 

FIFO Readout not working properly

BobSanders
Associate

Dear ST- Community,

we are currently implementing a new function to our existing device with the following function:

We want to detect, when the device is tilted. This function is not time critical at all. The most important fact is energy consumption.

We do have a LIS2DS12 accelerometer, connected via I2C. We want to collect ACC data with 12,5 Hz / LP for the max. time before we readout the FIFO. At the moment, we readout the FIFO every 20 sec. This get us ~250 samples.

The problem is, that if the time between readouts is longer than 9 sec., we can not read all samples (we take the FIFO_SRC reg. resp. the FIFO_Samples reg.). Our time delay is 10 sec., we expect 125 samples, the first time we get 125 samples, after the next readout only 17 samples afterwards again 125 samples and so on. If the time gets even longer, it looks like this:

 

FIFO Size: 113

Status Reg (0x27): 1

// readout

FIFO SAMPLES (0x30): 4 // check remaining samples

 

// delay 10 sec.

FIFO Size: 123

Status Reg (0x27): 1

// readout

FIFO SAMPLES (0x30): // check remaining samples

// delay 10 sec.

 All Interrupts are turned off, config is as follows:

 

LIS2DS12_CTRL2 (x21): 0xC1

LIS2DS12_CTRL1 (0x20): 0x91

LIS2DS12_FIFO_CTRL(0x25): 0xC0

LIS2DS12_WAKE_UP_THS (0x33): 0x3F

 

We readout via:

 

i2cWriteRead(LIS2DS12_ADDRESS,(uint8_t []){0x28},1,rxBuffer,fifoSize*6);

 

with memset(rxBuffer,0,sizeof(uint8_t) * 6 * fifoSize);

uint8_t rxBuffer[1536] = {0};

 

If, however we readout seperately like:

 // Read X

i2cWriteRead(LIS2DS12_ADDRESS,(uint8_t []){0x28},1,rxBufferX,fifoSize*2);

 

 // Read Y

 i2cWriteRead(LIS2DS12_ADDRESS,(uint8_t []){0x2A},1,rxBufferY,fifoSize*2);

 

 // Read Z

i2cWriteRead(LIS2DS12_ADDRESS,(uint8_t []){0x2C},1,rxBufferZ,fifoSize*2);

 

There is no problem but we need to communicate 3 times via the I2C instead of only once which is energywise costly.

 

Any ideas what we are missing?

 

Thank you so much!

0 REPLIES 0