After configuring the motion detection and data ready interrupts (MOT_EN and DATA_RDY_EN regs) and setting the motion detection threshold (MOT_THR reg) I tried to check its status by reading the reg INT_STATUS. The thing is that only DATA_RDY_INT is set. Bellow I atach my init function . What am I missing?
void MPU6050_Init(I2C_HandleTypeDef *hi2c){
uint8_t check_id,
Data;
// check device ID WHO_AM_I
if( HAL_OK == HAL_I2C_Mem_Read (hi2c, MPU6050_ADDR<<1,WHO_AM_I_REG,1, &check_id, 1, 1000)){
if (check_id == MPU6050_ADDR) // 0x68 will be returned by the sensor if everything goes well
{
// power management register 0X6B we should write all 0's to wake the sensor up
Data = 0;
HAL_I2C_Mem_Write(hi2c, MPU6050_ADDR<<1, PWR_MGMT_1_REG, 1,&Data, 1, 1000);
// Set DATA RATE of 1KHz by writing SMPLRT_DIV register
Data = 0x07;
HAL_I2C_Mem_Write(hi2c, MPU6050_ADDR<<1, SMPLRT_DIV_REG, 1, &Data, 1, 1000);
// Set accelerometer configuration in ACCEL_CONFIG Register
// XA_ST=0,YA_ST=0,ZA_ST=0, FS_SEL=0 -> ± 2g
Data = 0x00;
HAL_I2C_Mem_Write(hi2c, MPU6050_ADDR<<1, ACCEL_CONFIG_REG, 1, &Data, 1, 1000);
// Set Gyroscopic configuration in GYRO_CONFIG Register
// XG_ST=0,YG_ST=0,ZG_ST=0, FS_SEL=0 -> ± 250 °/s
Data = 0x00;
HAL_I2C_Mem_Write(hi2c, MPU6050_ADDR<<1, GYRO_CONFIG_REG, 1, &Data, 1, 1000);
//Enable the interrupts
Data = MOT_EN|DATA_RDY_EN;
HAL_I2C_Mem_Write (hi2c, MPU6050_ADDR<<1, INT_ENABLE, 1, &Data , 1,100);
//Set motion threshold
HAL_I2C_Mem_Write (hi2c, MPU6050_ADDR<<1, MOT_THR, 1, 10, 1,100);
}
}
}
In the main loop I call :
get_int_status = HAL_I2C_Mem_Read_DMA(hi2c, MPU6050_ADDR<<1, INT_STATUS, 1, &status, 1);
get_int_status = 1 instead of 001000001
Hi,
Have you checked out our eMD driver on our website? There are examples listed there, you can try to figure out how the setup works, and what might be wrong with yours.
https://invensense.tdk.com/developers/software-downloads/#smartmotion
I'll give a look
many thanks
I see lots of drivers. Could you please show me the one for the MPU6050?
I can see that the motion functiionality was discontinued in newer versions of the datasheet.
Hi,
Please refer to attached screenshot for MPU6050 driver.