高字节读出是0xff,低字节读出是0x00,
不明白什么原因。
void TMP275_Init()
{
//IIC_Init();
IIC_Start();
IIC_Write_Byte(0x96);
IIC_Wait_Ack();
IIC_Write_Byte(0x01);
IIC_Wait_Ack();
IIC_Write_Byte(0xFE);
IIC_Wait_Ack();
IIC_Stop();
}
u16 TMP275_Read_Byte()
{
u8 data_H,data_L;
u16 temp = 0;
IIC_Start();
IIC_Write_Byte(0x96);
IIC_Wait_Ack();
IIC_Write_Byte(0x00);
IIC_Wait_Ack();
IIC_Start();
IIC_Write_Byte(0x97);
IIC_Wait_Ack();
data_H = IIC_Read_Byte(1);
data_L = IIC_Read_Byte(0);
IIC_Stop();
temp = (((u16)data_H<<8)|data_L);
temp>>=4;
LED0 = ~LED0;
return temp;
}
一周热门 更多>