I am using the MMA8452Q. The device is configured to generate ASLP and TRANSIENT interrupts. When the device is tapped an interrupt is generated and after ASLP expires the SLEEP interrupt is generated and the device enters SLEEP. If tapped again while in SLEEP the device wakes, generates a TRANSIENT interrupt and enters SLEEP again when ASLP expires. The transient threshold is set to 0.063 g so only slight taps will generate the TRANSIENT interrupt. However, it takes a much harder tap to awaken the device than when it is awake. How can the acceleration required to wake the device be set to match the awake acceleration?
I have verified that the value in TRANSIENT_THS is the same when in SLEEP and AWAKE.
I found that by reducing the Transient Count from 2 to 0 reduced the acceleration required to wake from sleep. But still not as sensitive as when awake. I will also try increasing the Sleep ODR (at the expense of power consumption). It does not seem that the issue is slow response due to the lower ODR but rather a sensitivity issue. The threshold is set to 0.063g and when awake lightly touching the device triggers interrupts. When sleeping a much firmer tap is required to wake and interrupt.
MMA8452RegWrite(CTRL_REG1, STANDBY_MODE); // must be in standby to change registers (reg 0x2a = 0x00)
MMA8452RegWrite(XYZ_DATA_CFG_REG, (FULL_SCALE_RANGE_2G)); // +/- 2g full scale, hpf off (reg ox0e = 0x00)
MMA8452RegWrite(TRANSIENT_CFG_REG, (1 << ELE) | (1 << ZTEFE) | (1 << YTEFE) | (1 << XTEFE)); // latch flags, enable x,y,z transient detection, use hpf (reg 0x1d = 0x1e)
MMA8452RegWrite(TRANSIENT_THS_REG, (1 << DBCNTM) | TRANSIENT_THRESHOLD_COUNT);// debounce counter mode, threshold = 4 x .063g (reg 0x1f = 0x81)
MMA8452RegWrite(TRANSIENT_COUNT_REG, TRANSIENT_COUNT);// debounce counts (reg 0x20 = 0x02)
MMA8452RegWrite(ASLP_COUNT_REG, ASLP_COUNT); // sleep after 320ms x count (reg -x29 = 0x00)
MMA8452RegWrite(CTRL_REG1, (1 << ASLP_RATE1) | (1 << ASLP_RATE0)); // system odr = 800hz, remain in standby (reg 0x2a = 0xc0)
MMA8452RegWrite(CTRL_REG2, (1 << SMODS1) | (1 << SMODS0) | (1 << SLPE) | (1 << MODS1) | (1<< MODS0)); // low power sleep, enable auto-sleep, low power active state (reg 0x2b = 0x1f)
MMA8452RegWrite(CTRL_REG3, (1 << WAKE_TRANS)); // wake from transient interrupt, active low, push-pull (reg 0x2c = 0x40)
MMA8452RegWrite(CTRL_REG4, (1 << INT_EN_ASLP) | (1 << INT_EN_TRANS)); // enable SLEEP/WAKE interrupt, enable transient interrupt (reg 0x2d = 0xa0)
ctrl_reg1 = MMA8452RegRead(CTRL_REG1); // (reg 0x29 = 0xc0)
MMA8452RegWrite(CTRL_REG1, ctrl_reg1 | (1 << ACTIVE));// return to active mode (reg 0x29 = 0xc1)
I’d like to know how you configure the registers or settings other than the threshold, for instance, the ODR and TRANSIENT_COUNT register. These two registers are very important when using transient detection interrupts, because TRANSIENT_COUNT sets the number of debounce counts the tap or motion must last, and the time step for this counter is given by ODR.
When MMA8451Q is set to sleep the ODR is much lower than when is awake in order to reduce current consumption, this could lead to slower response to the tap or motion than when it’s awake.