初级会员
- 积分
- 121
- 金钱
- 121
- 注册时间
- 2015-9-30
- 在线时间
- 22 小时
|
为什么我读到的MPU9250磁力计AK8963的ID是0x7f,并不是0x48;且读到的磁力计数值为0xDF ,0xBF,0x3F,0xFF3F等基本都是以F结尾的数值;
初始化代码如下:
void Init_MPU9250(void)
{
unsigned char res;
Single_Write_MPU9250(GYRO_ADDRESS,PWR_MGMT_1, 0x00); //½â³ýÐÝÃß״̬
Single_Write_MPU9250(GYRO_ADDRESS,SMPLRT_DIV, 0x07);
Single_Write_MPU9250(GYRO_ADDRESS,CONFIG, 0x06);
Single_Write_MPU9250(GYRO_ADDRESS,GYRO_CONFIG, 0x18);
Single_Write_MPU9250(GYRO_ADDRESS,ACCEL_CONFIG, 0x00);
//Single_Write_MPU9250(GYRO_ADDRESS,MPU_INT_EN_REG,0X00); //¹Ø±ÕËùÓÐÖжÏ
//Single_Write_MPU9250(GYRO_ADDRESS,MPU_USER_CTRL_REG,0X00);//I2CÖ÷ģʽ¹Ø±Õ
//Single_Write_MPU9250(GYRO_ADDRESS,MPU_FIFO_EN_REG,0X00); //¹Ø±ÕFIFO
Single_Write_MPU9250(GYRO_ADDRESS,0x37,0x02);//turn on Bypass Mode
delay1ms(100);
res = Single_Read_MPU9250(GYRO_ADDRESS,WHO_AM_I);
if (res == 0x71)
{
Single_Write_MPU9250(GYRO_ADDRESS,PWR_MGMT_1, 0x01);
}
res=Single_Read_MPU9250(MAG_ADDRESS,MAG_WIA); //¶ÁÈ¡AK8963 ID
if(res==0x48)
{
Single_Write_MPU9250(MAG_ADDRESS,0x0A,0X11); //ÉèÖÃAK8963Ϊµ¥´Î²âÁ¿Ä£Ê½
}
}
void READ_MPU9250_MAG(void)
{
BUF[0]=Single_Read_MPU9250(MAG_ADDRESS,MAG_XOUT_L);
BUF[1]=Single_Read_MPU9250(MAG_ADDRESS,MAG_XOUT_H);
mag_x=(BUF[1]<<8)|BUF[0]; //¶ÁÈ¡¼ÆËãXÖáÊý¾Ý
BUF[2]=Single_Read_MPU9250(MAG_ADDRESS,MAG_YOUT_L);
BUF[3]=Single_Read_MPU9250(MAG_ADDRESS,MAG_YOUT_H);
mag_y= (BUF[3]<<8)|BUF[2]; //¶ÁÈ¡¼ÆËãYÖáÊý¾Ý
BUF[4]=Single_Read_MPU9250(MAG_ADDRESS,MAG_ZOUT_L);
BUF[5]=Single_Read_MPU9250(MAG_ADDRESS,MAG_ZOUT_H);
mag_z= (BUF[5]<<8)|BUF[4]; //¶ÁÈ¡¼ÆËãZÖáÊý¾Ý
Single_Write_MPU9250(MAG_ADDRESS,0x0A,0x11); ////AK8963ÿ´Î¶ÁÍêÒÔºó¶¼ÐèÒªÖØÐÂÉèÖÃΪµ¥´Î²âÁ¿Ä£Ê½,16λÊä³ö
delay1ms(50);
}
但是读MPU6500的ID是0x71,这个是正确的,这是怎么原因啊?
|
|