1.这边如果按0x00的从机地址可以获得 温度值 和 SMBus address=0xBE5A
2.如果按地址0x5A也是获取不到数据的,好奇怪!
3.现在把地址改为0xBE10,然后按0x10的从机地址去读取温度值好像无法得到返回值
4.手边只有一个MLX90614
5.请问是地址不对还是其他有问题,0xBE10是用0x00作为从机地址得到的返回值
在此谢谢各位了!
无缘无故的好了,我也没搞明白!
void EEPROM_WRITE(uchar slave_addW, uchar cmdW, uchar DataL, uchar DataH) //(地址,命令,写入值低,高)
{
uchar Pecreg; //Calculated PEC byte storage
uchar SLA;
uchar arr1[6]; //Buffer for the transmitted bytes
uchar error_timer = 0;
SLA=(slave_addW<<1);
arr1[5] = 0;
arr1[4] = SLA;
arr1[3] = cmdW;
arr1[2] = DataL;
arr1[1] = DataH;
arr1[0] = 0;
Pecreg = PEC_Calculation(arr1);
start();
SendByte(SLA);
SendByte(cmdW);
SendByte(DataL);
SendByte(DataH);
SendByte(Pecreg);
stop();
}
uchar PEC_Calculation(uchar pec[])
{
uchar crc[6];
uchar BitPosition=47;
uchar shift,i,j,temp;
do
{
/*Load pattern value 0x000000000107*/
crc[5]=0;
crc[4]=0;
crc[3]=0;
crc[2]=0;
crc[1]=0x01;
crc[0]=0x07;
/*Set maximum bit position at 47 ( six bytes byte5...byte0,MSbit=47)*/
BitPosition=47;
/*Set shift position at 0*/
shift=0;
/*Find first "1" in the transmited message beginning from the MSByte byte5*/
i=5;
j=0;
while((pec[i]&(0x80>>j))==0 && i>0)
{
BitPosition--;
if(j<7)
{
j++;
}
else
{
j=0x00;
i--;
}
}/*End of while */
/*Get shift value for pattern value*/
shift=BitPosition-8;
/*Shift pattern value */
while(shift)
{
for(i=5; i<0xFF; i--)
{
if((crc[i-1]&0x80) && (i>0))
{
temp=1;
}
else
{
temp=0;
}
crc[i]<<=1;
crc[i]+=temp;
}/*End of for*/
shift--;
}/*End of while*/
/*Exclusive OR between pec and crc*/
for(i=0; i<=5; i++)
{
pec[i] ^=crc[i];
}/*End of for*/
}
while(BitPosition>8); /*End of do-while*/
return pec[0];
}
IIC的地址只有7位