MPU6050使用DMP功能遇到问题
开始没有开DMP功能,用模拟I2C读取MPU6050的角速度和加速度值都可以,之后开启DMP功能,参考各位大神历程,只是inv_mpu.c添加了I2Cd的读写函数,运行之后的结果是,程序在mpu_init()处都没有通过,对mpu初始化失败。下边是部分程序代码:int result = 0;
result = mpu_init();
if(!result)
{
printf("mpu initialization complete......\n ");
if(!mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL)) // enable sensors
printf("mpu_set_sensor complete ......\n");
else
printf("mpu_set_sensor come across error ......\n");
if(!mpu_configure_fifo(INV_XYZ_GYRO | INV_XYZ_ACCEL)) //sensors_fifo_enable
printf("mpu_configure_fifo complete ......\n");
else
printf("mpu_configure_fifo come across error ......\n");
if(!mpu_set_sample_rate(DEFAULT_MPU_HZ)) //configure sample_rate
printf("mpu_set_sample_rate complete ......\n");
else
printf("mpu_set_sample_rate error ......\n");
if(!dmp_load_motion_driver_firmware()) //dmp_load_motion_driver_firmvare
printf("dmp_load_motion_driver_firmware complete ......\n");
else
printf("dmp_load_motion_driver_firmware come across error ......\n");
if(!dmp_set_orientation(inv_orientation_matrix_to_scalar(gyro_orientation))) //Configure
printf("dmp_set_orientation complete ......\n");
else
printf("dmp_set_orientation come across error ......\n");
if(!dmp_enable_feature(DMP_FEATURE_6X_LP_QUAT | DMP_FEATURE_TAP |
DMP_FEATURE_ANDROID_ORIENT | DMP_FEATURE_SEND_RAW_ACCEL | DMP_FEATURE_SEND_CAL_GYRO |
DMP_FEATURE_GYRO_CAL)) //dmp_enable_feature
printf("dmp_enable_feature complete ......\n");
else
printf("dmp_enable_feature come across error ......\n");
if(!dmp_set_fifo_rate(DEFAULT_MPU_HZ)) //dmp_set_fifo_rate
printf("dmp_set_fifo_rate complete ......\n");
else
printf("dmp_set_fifo_rate come across error ......\n");
run_self_test();//AUTOself check
if(!mpu_set_dmp_state(1)) // Enable the function of DMP
printf("mpu_set_dmp_state complete ......\n");
else
printf("mpu_set_dmp_state come across error ......\n");
} 程序编译时是没问题的 发现一个问题,我在封装I2C读写函数时,返回值居然不是0而是非0值。已经修改,但是还是不行 看了下inv_mpu.c里给的设备地址是0x68,我现在用的是模拟串口应该修改成0XD0。修改好果断可以
mpu initialization complete......
mpu_set_sensor complete ......
mpu_configure_fifo complete ......
mpu_set_sample_rate complete ......
然后到加载DPM配置这一项的时候死了,不知道有没有遇上同样问题解决的,给点参考 哎,终于发现自己错在哪里了。在 mpu_load_firmware()函数里有一个for循环,计算一下需要循环192次。在minicom上显示调试结果太慢了,执行一次循环要2,3十秒,看上去就像程序死那里了一样
哎,问题最终还是找到了。模拟I2C时钟的问题 你好,我也是遇到了DMP初始化卡死的问题,程序执行到inv_mpu.c文件中的int mpu_init(void)函数时,在第一步Reset device便失败了,
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, data))
return -1;
就是这一步直接返回-1,肯定是错了,实在是找不到原因,还请指点指点!谢谢
页:
[1]