Hello, i am trying to read SPI temp from DS1722. Read OK but, values is not linear. Code and example of value:
void DS1722_Init();
int Read_Temp();
int MSB, LSB;
int i_Temp;
float f_Temp;
int Temp_for_print;
void DS1722_Init()
{
CS_DS1722_1;
SPI_Write(0x80);
SPI_Write(0xE8);
CS_DS1722_0;
}
int Read_Temp()
{
CS_DS1722_1;
SPI_Write(0x01);
SPI_Write(0x00);
LSB = UCA0RXBUF;
SPI_Write(0x00);
MSB = UCA0RXBUF;
while((UCA0STAT&UCBUSY));
CS_DS1722_0;
i_Temp = ((MSB << 8) | LSB);
f_Temp = i_Temp;
Temp_for_print = ((f_Temp / 128) * 10); // I now this value using to print display
return Temp_for_print;
}
x = Temp_for_print / 100;
y = (Temp_for_print % 100) / 10;
z = (Temp_for_print % 100) % 10;
Value (xy , z):
26,4
26,3
26,2
26,1
26,0
24,7
24,6
24,5
Where is 25th value? I am try to MSB, LSB set as unsigned char or long... always same problem
Thank You