2025-11-13 12:41 AM
Hi everyone,
I'm using 2 LIS2DU12 on one object.
The first one is configured in continuous mode. I forward the samples directly to a computer. I use it to check the wake up triggering configuration of the second one.
The second one is configured in continuous-to-FIFO mode. And I'm trying to get it to wake up when the acceleration on one axis is over 2g for at least 8.75ms. ODR is 800Hz, FS=16g, so I set :
WK_THS=8
WAKE_THS_W=0
=> threshold = 2g x 2⁶ / 16g = 8
WAKE_DUR=01 (7 ODR_time)
WU_DUR_X4=1
=> Wake-up duration = 7 / 800 = 8.75ms
The first LIS2DU12 configured in continuous mode shows that during my tests I get 4g for over 20ms, yet the second LIS2DU12 does not wake up. But if I set the threshold to 4 (i.e. 1g according to my calculations) it does wake up, and I recover 2 very similar acquisitions.
What did I misunderstand ?
Here is a code snippet of the configuration of the LIS2DU12 in continuous-to-FIFO mode:
lis2du12_pin_int_route_t int_route;
lis2du12_status_t status;
lis2du12_id_t id;
/* Initialize mems driver interface */
dev_ctx.write_reg = spi_write;
dev_ctx.read_reg = spi_read;
dev_ctx.mdelay = platform_delay;
dev_ctx.handle = p_bus;
/* Wait sensor boot time */
platform_delay(BOOT_TIME);
/* Check device ID */
lis2du12_id_get(&dev_ctx, &id);
if (id.whoami == LIS2DU12_ID)
{
printf("-Part ID: 0x%02X\r\n", id.whoami);
}
else
{
printf("Echec Lecture ID...\r\n");
}
/* Restore default configuration */
lis2du12_init_set(&dev_ctx, LIS2DU12_RESET);
do {
lis2du12_status_get(&dev_ctx, &status);
} while (status.sw_reset);
/* Set bdu and if_inc recommended for driver usage */
lis2du12_init_set(&dev_ctx, LIS2DU12_DRV_RDY);
// Configure CTRL 5 en power down
md.odr = LIS2DU12_OFF;
lis2du12_mode_set(&dev_ctx, &md);
// configure mode Wake up
// Activer la détection sur X, Y et Z
wkup_md.x_en = 1;
wkup_md.y_en = 1;
wkup_md.z_en = 1;
wkup_md.threshold = 8; // Thres=±2g, FS=±16g, 1LSB of thres=FS/2^6 => 2g*2⁶/16g=2³
wkup_md.duration = 5; // 5 => WU_DUR_X4=1 & WAKE_DUR=1 => duration=7 ODR_time =7/800Hz=8,75ms
wkup_md.sleep.en = 0;
lis2du12_wake_up_mode_set(&dev_ctx,&wkup_md);
/* Select bus interface */
lis2du12_bus_mode_set(&dev_ctx, LIS2DU12_I3C_DISABLE);
/* Set FIFO watermark to 64 sample(s) */
fifo_mode.store = LIS2DU12_8_BIT;
fifo_mode.watermark = 64;
fifo_mode.operation = LIS2DU12_STREAM_TO_FIFO;
lis2du12_fifo_mode_set(&dev_ctx, &fifo_mode);
// CONFIGURE CTRL 5 en 16g et ODR de 800Hz
/* Set Output Data Rate */
md.fs = LIS2DU12_16g;
md.odr = LIS2DU12_800Hz;
lis2du12_mode_set(&dev_ctx, &md);
/* Configure interrupt pins */
lis2du12_pin_int2_route_get(&dev_ctx, &int_route);
int_route.wake_up = PROPERTY_ENABLE;
lis2du12_pin_int2_route_set(&dev_ctx, &int_route);
2025-11-13 7:54 AM
Hi @Ch4rly ,
Some suggestions:
Hope this helps!
2025-11-17 12:45 AM
Hi Federica,
Thanks for the reply.
I checked that's what "lis2du12_wake_up_mode_set" does : WU_DUR_X4=1 and WAKE_DUR=01.
Does my calculations make sense to you ?
2025-11-26 6:44 AM
Hi @Federica Bossi,
Thanks for the reply.
I checked that's what "lis2du12_wake_up_mode_set" does : WU_DUR_X4=1 and WAKE_DUR=01.
That being said. Does my calculations for
make sense to you ?