Here I've issue related to
DS1621 digital thermometer interfacing with PIC18F26J50 controller.
Below you can see my code and this code I build in MPLAB X v.1.4 IDE with C18 compiler:
unsigned char i2c_read(void)
{
char buf[20];
unsigned char i,j;
j=0;
i=DATA;
for(i=0;i<8;i++)
{
j<<=1;
CLOCK = HIGH;
j|=DATA;
delay_ms(100);
CLOCK = LOW;
}
//////////////////////
**sprintf(buf,"%d",j); // 255
transmit_str1(buf); //UART transmit string**
/////////////////////
return buf;//return j;
}
main()
{
while(1)
{
i2c_start();
i2c_write(0x90);
i2c_write(0xAC);
i2c_write(0x02);
i2c_stop();
i2c_start();
i2c_write(0x90);
i2c_write(0xEE);
i2c_stop();
i2c_start();
i2c_write(0x90);
i2c_write(0xAA);
i2c_start();
i2c_write(0x91);
ch = i2c_read();
i2c_stop();
///////////////////
temperature = 0;
convert(ch); //convert binary to Decimal
if(flag==FALSE_)
{
flag = TRUE_;
tmp=temperature;
//itoa(tmp,buffer);
sprintf(tmp,"%s",temperature);
}
else
{
if(tmp!=temperature)
{
tmp=temperature;
sprintf(str,"%d%s",temperature,"Centigrade");
}
}
}
}
Here I'm interfacing DS1621 Thermometer with PIC18F26J50.
and I'm doing I2C communication between them. and I see this result on UART, but I get "255" data.
This "255" data string I got from "i2c_read(void)" function.
Here I'm attaching a screenshot of Oscilloscope from Proteus software. (YELLOW: SDA | BLUE: SCL).
Can you please tell me how to get reading from DS1621?