2021-08-30 02:44 AM
I have a simple task, to wake up the CPU when the device is shaken.
It should be pretty simple, the MEMS sensor samples with 10Hz until I shake it, then it samples with 100Hz, but I get no interrupt. :(
I use the driver form GIT hub and Interrupt INT1
https://github.com/STMicroelectronics/lis2de12/tree/21b9d1a565882a242143453580efb6abcd450686
My CODE:
/* Set full scale to 2g */
lis2de12_full_scale_set(&(phandler->ctx), LIS2DE12_2g);
/* route HP filter output on outputs registers */
lis2de12_high_pass_on_outputs_set(&(phandler->ctx), PROPERTY_ENABLE);
/* route HP filter output on interrupt generator 1 */
lis2de12_high_pass_int_conf_set(&(phandler->ctx), LIS2DE12_ON_INT1_INT2_GEN);
/* HP filter mode is "autoreset on inteerupt event" */
lis2de12_high_pass_mode_set(&(phandler->ctx), LIS2DE12_NORMAL_WITH_RST);
/* Set HP filter on mode */
lis2de12_high_pass_bandwidth_set(&(phandler->ctx), LIS2DE12_AGGRESSIVE);
/* Configure interrupt on threshold on x,y,z axis low / high events */
lis2de12_int1_cfg_t lis2de12_int1_cfg = {0};
lis2de12_int1_cfg.xhie = PROPERTY_ENABLE;
lis2de12_int1_cfg.yhie = PROPERTY_ENABLE;
lis2de12_int1_cfg.zhie = PROPERTY_ENABLE;
lis2de12_int1_gen_conf_set(&(phandler->ctx), &lis2de12_int1_cfg);
lis2de12_ctrl_reg3_t lis2de12_ctrl_reg3 = {0};
lis2de12_ctrl_reg3.i1_ia1 = PROPERTY_ENABLE;
lis2de12_ctrl_reg3.i1_ia2 = PROPERTY_ENABLE;
lis2de12_pin_int1_config_set(&(phandler->ctx), &lis2de12_ctrl_reg3);
lis2de12_lir_int1_t lis2de12_lir_int1;
lis2de12_lir_int1 = LIS2DE12_INT1_LATCHED;
lis2de12_int1_pin_notification_mode_set(&(phandler->ctx),lis2de12_lir_int1);
/* Set interrupt threshold at ~160 mg -> 1bit = 16mg@2g */
lis2de12_int1_gen_threshold_set(&(phandler->ctx), 10);
/* Set duration to zero - 1 bit = 1/ODR */
lis2de12_int1_gen_duration_set(&(phandler->ctx), 2);
/* Set Output Data Rate to 100Hz */
lis2de12_data_rate_set(&(phandler->ctx), LIS2DE12_ODR_100Hz);
lis2de12_act_threshold_set(&(phandler->ctx), (1000/16));
lis2de12_act_timeout_set(&(phandler->ctx), 10);
hope there is someone who can give a hint.
Solved! Go to Solution.
2021-08-30 06:22 AM
Hi, searching in the github examples, various examples implementing wake-up feature set duration of the event equal to 0 (I see you are setting 2):
/* Apply high-pass digital filter on Wake-Up function
* Duration time is set to zero so Wake-Up interrupt signal
* is generated for each X,Y,Z filtered data exceeding the
* configured threshold
*/
lis2ds12_wkup_dur_set(&dev_ctx, 0);
Moreover, they set a lower Interrupt threshold, typ 02h.
Did you check other interrupts as for example the data ready I1_ZYXDA one?
\Dk
2021-08-30 06:22 AM
Hi, searching in the github examples, various examples implementing wake-up feature set duration of the event equal to 0 (I see you are setting 2):
/* Apply high-pass digital filter on Wake-Up function
* Duration time is set to zero so Wake-Up interrupt signal
* is generated for each X,Y,Z filtered data exceeding the
* configured threshold
*/
lis2ds12_wkup_dur_set(&dev_ctx, 0);
Moreover, they set a lower Interrupt threshold, typ 02h.
Did you check other interrupts as for example the data ready I1_ZYXDA one?
\Dk
2021-08-30 06:43 AM
setting the duration to 0 dit the work!
Thanks, you the best..