CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

TC74

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

TC74
PostPosted: Mon Mar 15, 2004 4:12 pm     Reply with quote

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
   }
}
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Tue Mar 16, 2004 2:12 am     Reply with quote

Hello Neutone,
Unbelievable, you give the answer before I can ask the question. Go on!!! Very Happy

73 Sven
tag-eng



Joined: 28 Jul 2004
Posts: 6

View user's profile Send private message Visit poster's website

PostPosted: Wed Jul 28, 2004 11:44 am     Reply with quote

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.

thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group