根据例程编写的代码,写入正常运行,但是一直卡在FIFO为空检测,一直读取不了数据
void MPU6050_ReadReg(uint8_t RegAddress)
{
DL_I2C_fillControllerTXFIFO(I2C_INST, &RegAddress, 1);//将要发送的数据填入TXFIFO
while (!(
DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))//检测I2C是否空闲
;
DL_I2C_startControllerTransfer(I2C_INST,MPU6050_ADDRESS,DL_I2C_CONTROLLER_DIRECTION_TX,1);
// DL_I2C_transmitControllerData(I2C_INST,0x75);
// DL_I2C_transmitControllerData(I2C_INST,0x75);
while (!(
DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))//检测I2C是否空闲
;
DL_I2C_flushControllerTXFIFO(I2C_INST);
DL_I2C_flushControllerRXFIFO(I2C_INST);
delay_cycles(1000);
DL_I2C_startControllerTransfer(I2C_INST,MPU6050_ADDRESS,DL_I2C_CONTROLLER_DIRECTION_RX,1);
while (DL_I2C_isControllerRXFIFOEmpty(I2C_INST));
data_r = DL_I2C_receiveControllerData(I2C_INST);
int data = data_r;
OLED_ShowNum(0,0,data_r,3,16);
}
更多回帖