How to enable the wake on motion mode of mpu6500

By cghabros , 2 December 2015

I've write the code as the datasheet 5.1 section: Wake-on-Motion Interrupt, but when I flip the z axis, then read out using i2c bus, the z axis sign bit is not changed.
void MPU6500_StartMotionDetection(void)
{
data = MPU6500_CONFIG_LPFILTER_184Hz;
MPU6500_WriteRegister(MPU6500_CONFIG_ADR, data);

/* enable motion interrupt */
data = MPU6500_INT_ENABLE_MOT_EN;
MPU6500_WriteRegister(MPU6500_INT_ENABLE_ADR, data);

data = 0xC0; /* Enable the int detect logic*/
MPU6500_WriteRegister(MPU6500_ACCEL_INTEL_CTRL, data);

/* set Motion Detection Threshold */
data = 0x06; /* unit is mg/LSB (gravity is removed by motion select logic)*/
MPU6500_WriteRegister(MPU6500_MOT_THR_ADR, data);

/* Set accelerometer full scale range settings */
data = (MPU6500_ACCEL_CONFIG_AFSEL_FS2G );
MPU6500_WriteRegister(MPU6500_ACCEL_CONFIG_ADR, data);

/* Set the frequency of wake-up and to 20Hz and disable gyro */
data = 0xC0 | MPU6500_PWR_MGMT_2_STBY_ZG | \
MPU6500_PWR_MGMT_2_STBY_YG | MPU6500_PWR_MGMT_2_STBY_XG;
MPU6500_WriteRegister(MPU6500_PWR_MGMT_2_ADR, data);

/* configuration interrupt */
data = (MPU6500_INT_PIN_CFG_LATCH_INT_EN | MPU6500_INT_PIN_CFG_I2C_BYPASS_EN);
MPU6500_WriteRegister(MPU6500_INT_PIN_CFG_ADR, data);

/* clear interrupt flag */
MPU6500_WriteRegister(MPU6500_INT_STATUS_ADR, data);

/* set output data rate value (ODR value) */
data = 6;
MPU6500_WriteRegister(MPU6500_LP_ACCEL_ODR_ADR, data);

/* Enable Cycle Mode (Low Power Mode)*/
data = ( MPU6500_PWR_MGMT_1_INTERNALOSC | MPU6500_PWR_MGMT_1_CYCLE | MPU6500_PWR_MGMT_1_TEMP_DIS );
MPU6500_WriteRegister(MPU6500_PWR_MGMT_1_ADR, data);
}

phpbb Topic ID
31678