I spent a morning remembering how to use I2C. I had trouble finding any code example for the TC74 on the PICDEM2+ dev board. The killer was not readings the data sheet reguarding the address. Then I had to adjust for the signed byte.
Code:
/**********************************************************/
/* Read Temp TC74 on PICDEM2+ */
/**********************************************************/
void Read_Temperature(void)
{ int16 Temperature;
if(Get_Temp)
{ Get_Temp=0;
i2c_Start(); // Set a START condition I2C Bus
i2c_Write(0b10011010); // Address and Write Flag
i2c_Write(0x00); // Temperature Register
i2c_Start(); // Set a START condition I2C Bus
i2c_Write(0b10011011); // Address and Read Flag
Temperature = i2c_Read(); // Read Teperature
i2c_stop();
if(Temperature>=128)
{ Temperature+=0xFF00; // Fill upper byte
}
Temperature+=273; // Make it a kelvin reading
}
}
Hello Neutone,
Unbelievable, you give the answer before I can ask the question. Go on!!!
73 Sven
tag-eng
Joined: 28 Jul 2004 Posts: 6
Posted: Wed Jul 28, 2004 11:44 am
neutone (or anyone),
thanks for the code. we were wondering how you got this to print out? also, the headers and things that are used with the i2c. so basicly what i am looking for is a way to output the data gathered here and everything necessary to make this run properly.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum