AnsweredAssumed Answered

MMA8451Q motion detecion

Question asked by cai bai on Sep 23, 2016
Latest reply on Sep 23, 2016 by cai bai

hi,i want use MMA8451Q to detect move and init it as

bool MMA8451Q_Init(void){

    unsigned char val;

    /* Place the MMA8451Q in sleep mode,ODR 100HZ */
    MMA8451Q_WriteReg(0x2A,0x18);
    /* motion detection,enable XYZ */
    MMA8451Q_WriteReg(0x15,0xD8);
    /* set threshold */
    MMA8451Q_WriteReg(0x17,0x08);
    MMA8451Q_WriteReg(0x18,0x0A);
    /* enable motion dection interrupt */
    MMA8451Q_WriteReg(0x2D,0x04);
    /* set interrupt pin */
    MMA8451Q_WriteReg(0x2E,0x04);
#if 0
    /* Set on-board Acc sensor range to 8G */
    MMA8451Q_WriteReg(0x0E,0x02);
#endif
    val = MMA8451Q_ReadReg(0x2A);
    MMA8451Q_WriteReg(0x2A,val | 0x01);
    /* Acc sensor WHO_AM_I check... */
    if (0x1A == MMA8451Q_ReadReg(0x0D)){
        MMA8451Q_GpioIntInit();
        return true;
    }else{
        return false;
    }

}

 

after init ,i read  some of reg and print as follow

Reg addr  <-->  val

Reg 0x09 <--> 0x00
Reg 0x0a <--> 0x00
Reg 0x0b <--> 0x01
Reg 0x0c <--> 0x00
Reg 0x0d <--> 0x1a
Reg 0x0e <--> 0x00
Reg 0x0f <--> 0x00
Reg 0x10 <--> 0x00
Reg 0x11 <--> 0x80
Reg 0x12 <--> 0x00
Reg 0x13 <--> 0x44
Reg 0x14 <--> 0x84
Reg 0x15 <--> 0xd8
Reg 0x16 <--> 0x00
Reg 0x17 <--> 0x08
Reg 0x18 <--> 0x0a
Reg 0x1d <--> 0x00
Reg 0x1e <--> 0x00
Reg 0x1f <--> 0x00
Reg 0x20 <--> 0x00
Reg 0x21 <--> 0x00
Reg 0x22 <--> 0x00
Reg 0x23 <--> 0x00
Reg 0x24 <--> 0x00
Reg 0x25 <--> 0x00
Reg 0x26 <--> 0x00
Reg 0x27 <--> 0x00
Reg 0x28 <--> 0x00
Reg 0x29 <--> 0x00
Reg 0x2a <--> 0x19
Reg 0x2b <--> 0x00
Reg 0x2c <--> 0x00
Reg 0x2d <--> 0x04
Reg 0x2e <--> 0x04
Reg 0x2f <--> 0x00
Reg 0x30 <--> 0x00
Reg 0x31 <--> 0x00

 

iic work OK,and reg value is right,but i can't recv any interrupt signal from MMA8451Q.

i read reg 0x0C(INT_SOURCE) in a dead loop and print it,it always is 0x00.

can you help me?

Outcomes