工具/软件:Code Composer Studio
HII、
我尝试使用传感器控制器从 cc350STK 读取湿度和温度传感器数据、但变量 I2C_STATUS 始终显示为1、输出始终为零。
SCL = DIO6
SDA = DIO5
SCL 频率= 400kHz
SCL 拉伸超时= 10us
下面是它的执行代码。
U16 tem_resh = 0;
U16 TEM_RESL = 0;
U16 hum_resh = 0;
U16 hum_resl = 0;
//湿度传感器配置
i2cStart();
i2ctx ((0x40<1)| I2C_OP_WRITE);
i2cTx (0x02);
i2cTx (0x10);
i2cTx (0x00);
i2cStop();
fwDelayU (100000、FW_DELAY_RANGE_100_MS);
针对温度0x00的//触发测量
i2cStart();
i2ctx ((0x40<1)| I2C_OP_WRITE);
i2cTx (0x00);
i2cStop();
fwDelayU (100000、FW_DELAY_RANGE_100_MS);
//if (state.i2cStatus = 0x0000){
i2cStart();
i2ctx ((0x40<1)| I2C_OP_READ);
i2cRxAck (tem_resh);
i2cRxAck (tem_resL);
i2cRxAck (hum_resh);
i2cRxNack (hum_resL);
i2cStop();
//}
output.temH = tem_resL;
output.Templ = tem_resh;
output.humH = hum_resh;
output.humL = hum_resL;
if (hum_resL > 0x00){
fwGenAlertInterrupt();
}
//安排下一次执行
fwScheduleTask (1);