TIwilliam hill官网
直播中

cc

未满1年用户 3经验值
擅长:控制/MCU
私信 关注
[问答]

MSPM0L1306 硬件I2C 读取MPU6050 接受数据FIFO一直为空

根据例程编写的代码,写入正常运行,但是一直卡在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);
}

更多回帖

发帖
×
20
完善资料,
赚取积分