InNeedOfHelp
Full Member level 3
- Joined
- Dec 5, 2012
- Messages
- 169
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,298
- Activity points
- 2,205
#define TC74_READ 0x9B
#define TC74_WRITE 0x9A
//////////////////////////////////////////////////////////////
void tc74_write(unsigned char reg,unsigned char val)
{
i2c_start();
i2c_write(TC74_WRITE);
i2c_write(reg);
i2c_write(val);
i2c_stop();
}
//////////////////////////////////////////////////////////////
void tc74_read(unsigned char reg,unsigned char *value)
{
i2c_start();
i2c_write(TC74_WRITE);
i2c_write(reg);
i2c_repStart();
i2c_write(TC74_READ);
*value=i2c_read(0); //ACK
i2c_stop();
}
signed int8 TC74_read_temperature(void)
{
signed int8 retval;
i2c_start();
i2c_write(TC74_WRITE);
i2c_write(TC74_READ);
i2c_start(); // Re-start
i2c_write(TC74_READ);
retval = i2c_read(0);
i2c_stop();
return(retval);
}
void main()
{
signed int8 temp;
while(1)
{
temp = TC74_read_temperature();
printf("Temperature (C) = %d\n\r", temp);
delay_ms(1000);
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?