below is my code to display temperature on lcd. I am using PicDem 2 Plus board along with MPLab IDE. I don't seem to get anything on the lcd screen. The lcd is working fine since I tried writing to it and it displays it. I think the problem is where i am reading data off of the temp sensor.
any help please, thank you.
any help please, thank you.
Code:
#pragma code
void main()
{
unsigned char i2c_addr = 0x9A; //b'10011010;
unsigned char i2c_addr_read = 0x9B; //b'10011011
unsigned char i2c_tempRegAddr = 0x00;
unsigned char readTemp='a';
TRISB = 0x00; //port b bits all output
XLCDInit(); //initialize lcd
XLCDClear(); //clear LCD
XLCDCursorOnBlinkOn(); //blinking cursor
XLCDL1home(); //go to line 1
OpenI2C(MASTER, SLEW_ON);
StartI2C(); //start condition
WriteI2C(i2c_addr); //select which i2c device
AckI2C(); //acknowledge condition
WriteI2C(i2c_tempRegAddr); //select temperature register
AckI2C();
StopI2C();
while (1)
{
StartI2C();
WriteI2C(i2c_addr_read); //read address
AckI2C();
if (DataRdyI2C())
{
readTemp = getcI2C();
PORTB = readTemp;
XLCDPut(readTemp);
}
//readTemp = ReadI2C(); //grab byte
StopI2C();
}
}