Hello Wlodek_D.
I have refer App note AN4070 for configuring motion detection.
I am working with FRDM board with CW 10.3
My initialization is as
MMA8451_WriteReg(MMA8451_CTRL_REG_1, 0x018);
//Set the device in 100 Hz ODR, Standby
MMA8451_WriteReg(0x15, 0xC8);
//Set Configuration Register for Motion Detection
MMA8451_WriteReg(0x17, 0x16);
// Motion detection of > 1g
MMA8451_WriteReg(0x18, 0x0A);
// Set De bounce counter 100 ms/10 ms (steps) = 10 counts;
MMA8451_WriteReg(0x2D, 0x04);
//Enable Motion/Freefall Interrupt Function in the System
MMA8451_WriteReg(0x2E, 0x04);
//Route the Motion/Freefall Interrupt Function to INT1
MMA8451_ReadReg(MMA8451_CTRL_REG_1,(uint8_t*)&xyz,1);
CTRL_REG1_Data = xyz[0];
CTRL_REG1_Data |=0x01;
MMA8451_WriteReg(MMA8451_CTRL_REG_1, CTRL_REG1_Data);
//Set active mode
I have set the threshold only for X axis.
At power on i am getting an interrupt but when i read 0X0C resister its value is 0x00 instead of 0x04
My interrupt routine is as
| | MMA8451_ReadReg(0x0C, (uint8_t*)&Data,1); |
| | if(Data[0]==0x04) |
| | { |
| | MMA8451_ReadReg(0x16, (uint8_t*)&Data,1); |
| | Green_LED_SetVal(NULL); |
| | } |
I am not getting interrupt after this reading 0x0C.
Please guide me if i am going in wrong direction.