|
发表于 2015-7-14 22:13:59
|
显示全部楼层
我的复位后还是一样,只有ID读得出来,其余读出来的数据是0。
void MPU6050(void)
{
I2C_InitTypeDef I2C_Con;
I2C_Con.I2C_Mode=I2C_Mode_I2C;
I2C_Con.I2C_DutyCycle=I2C_DutyCycle_2;
I2C_Con.I2C_OwnAddress1=0x00;
I2C_Con.I2C_Ack=I2C_Ack_Enable;
I2C_Con.I2C_AcknowledgedAddress=I2C_AcknowledgedAddress_7bit;
I2C_Con.I2C_ClockSpeed=50000;
I2C_ITConfig(I2C1,I2C_IT_BUF|I2C_IT_EVT ,DISABLE);
I2C_Init(I2C1,&I2C_Con);
I2C_Cmd(I2C1,ENABLE);
I2C_AcknowledgeConfig(I2C1,ENABLE);
Delay_Ms(1000);
I2C_WriteByte(0xD0,0x6B,0x80);
Delay_Ms(200);
I2C_WriteByte(0xD0,0x6B,0x00);
Delay_Ms(200);
I2C_WriteByte(0xD0,0x19,0x07); //SMPLRT_DIV
I2C_WriteByte(0xD0,0x1A,0x06); //Config
I2C_WriteByte(0xD0,0x1B,0x18); //GYRO_CONFIG
I2C_WriteByte(0xD0,0x1C,0x01); //ACCEL_CONFIG
USART_SendData(USART1,I2C_ReadByte(0xD0,0x41));
}
|
|