cancel
Showing results for 
Search instead for 
Did you mean: 

How to use extra 9K flash memory in LSM5DSO for storing accelerometer and gyroscope data

JChac.1
Associate

Hi,

I am using LSM6DSOx for a wearable device project. Currently all the accelerometer data is written in FIFO and device wait for data ready interrupt. This helps system to maintain low power mode and operate only when FIFO data is ready.

Currently FIFO is using only 3K of memory. But I want to use the additional 9K flash memory so that I can increase system sleep period.

Below is the accelerometer configurations that I am using. Please guide me what changes needs to be done to use 9K flash memory

------------------------------------------------------

/* Restore default configuration */

lsm6dsox_reset_set(&dev_ctx, PROPERTY_ENABLE);

ACCL_DEBUG("Sent reset command\r\n");

do {

lsm6dsox_reset_get(&dev_ctx, &rst);

} while (rst);

/* Disable I3C interface */

lsm6dsox_i3c_disable_set(&dev_ctx, LSM6DSOX_I3C_DISABLE);

/* Enable Block Data Update */

lsm6dsox_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);

/* Set full scale */

lsm6dsox_xl_full_scale_set(&dev_ctx, LSM6DSOX_2g);

lsm6dsox_xl_data_rate_set(&dev_ctx, LSM6DSOX_XL_ODR_OFF);

/*

* Set FIFO watermark (number of unread sensor data TAG + 6 bytes

* stored in FIFO) to 10 samples

*/

//lsm6dsox_fifo_watermark_set(&dev_ctx, 0x1FF);

/* Set FIFO batch XL/Gyro ODR to 12.5Hz */

lsm6dsox_fifo_xl_batch_set(&dev_ctx, LSM6DSOX_XL_BATCHED_AT_104Hz);

/* Set FIFO mode to Stream mode (aka Continuous Mode) */

lsm6dsox_fifo_mode_set(&dev_ctx, LSM6DSOX_STREAM_MODE);

/* Enable drdy 75 μs pulse: uncomment if interrupt must be pulsed */

/* Uncomment if interrupt generation on Free Fall INT1 pin */

lsm6dsox_pin_int1_route_get(&dev_ctx, &int1_route);

int1_route.fifo_th = PROPERTY_ENABLE;

int1_route.fifo_full = PROPERTY_ENABLE;

int1_route.fifo_ovr = PROPERTY_ENABLE;

int1_route.fifo_bdr = PROPERTY_ENABLE;

lsm6dsox_pin_int1_route_set(&dev_ctx, int1_route);

/* Uncomment if interrupt generation on Free Fall INT2 pin */

//lsm6dsox_pin_int2_route_get(&dev_ctx, &int2_route);

//int2_route.reg.int2_ctrl.int2_fifo_th = PROPERTY_ENABLE;

//lsm6dsox_pin_int2_route_set(&dev_ctx, &int2_route);

/* Set Output Data Rate */

lsm6dsox_xl_data_rate_set(&dev_ctx, LSM6DSOX_XL_ODR_104Hz);

lsm6dsox_compression_algo_init_set(&dev_ctx, 1);

lsm6dsox_compression_algo_set(&dev_ctx, LSM6DSOX_CMP_ALWAYS);

lsm6dsox_emb_sens_t emb_sens;

emb_sens.fifo_compr = PROPERTY_ENABLE;

lsm6dsox_embedded_sens_set(&dev_ctx, &emb_sens);

2 REPLIES 2
niccolò
ST Employee

Hi @JChac.1​ ,

as the datasheet states: "In order to maximize the amount of accelerometer and gyroscope data in FIFO, the user can enable the compression algorithm by setting to 1 both the FIFO_COMPR_EN bit in EMB_FUNC_EN_B (05h) (embedded functions registers bank) and the FIFO_COMPR_RT_EN bit in FIFO_CTRL2 (08h)"

you are already doing this by using functions

lsm6dsox_compression_algo_init_set(&dev_ctx, 1);

lsm6dsox_compression_algo_set(&dev_ctx, LSM6DSOX_CMP_ALWAYS);

what is the issue you are facing?

Niccolò

JChac.1
Associate

Hi Niccolo,

Initially I tried without the compression algorithm. In that case I can see 511 samples of accelerometer is saved in FIFO. And running at 100Hz, I get FIFO data ready interrupt in every 10s.

However after enabling the compression also, I see the same behavior. There are only 511 samples of accelerometer and interrupt is received every 10s. My expectation is that since the storage increased from 3K to 9K, I should get interrupt at 30s instead of 10s and number of samples in FIFO should be 3 times.

Regards,

Jiju