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 support@ccsinfo.com

TC74 problem

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 19, 2004 3:59 pm     Reply with quote

I would try a more simple test program. Here is one that I made
for the TCN75, which is a similar chip. It displays this output:

Start
Reading Temperature
Temp = 26
Temp = 28
Temp = 28
Temp = 27
Temp = 27
Temp = 28
Temp = 27
Temp = 26
Temp = 26
Temp = 27
Temp = 27
Temp = 27
Temp = 27
Temp = 27

It's not perfect, but it doesn't jump around as much as your
output does. (I have a heater running near the board. That's
why it's so warm).

Code:
#include <18F458.H>

#fuses XT, NOPROTECT, PUT, NOBROWNOUT, NOWDT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, errors)

#define TCN75_SDA PIN_C0
#define TCN75_SCL PIN_C1
#use i2c(Master, SDA=TCN75_SDA, SCL=TCN75_SCL)     // Software i2c

//------------------------------------------------------------------------
// DEFINES

// TCN75 i2c addresses
#define TCN75_I2C_WRITE_ADDR  0x90
#define TCN75_I2C_READ_ADDR   0x91

// TCN75 register addresses
#define TCN75_TEMP_REG_ADDR    0
#define TCN75_CONFIG_REG_ADDR  1
#define TCN75_THYST_REG_ADDR   2
#define TCN75_TSET_REG_ADDR    3

#define TCN75_CONFIG_VALUE     0x1A    // From Microchip TB052 appnote

//---------------------------------------------------------------------------
// FUNCTION PROTOTYPES
void TCN75_init(void);
char TCN75_read_temperature(void);

//=========================================

void main()
{
char result;

printf("Start\n\r");

TCN75_init();

printf("Reading Temperature\n\r");

while(1)
  {
   result = TCN75_read_temperature();
   printf("Temp = %d \n\r", result);
   delay_ms(1000);
  }
}

//=======================================

void TCN75_init(void)
{
 output_float(TCN75_SDA);
 output_float(TCN75_SCL);

 i2c_start();
 i2c_write(TCN75_I2C_WRITE_ADDR);
 i2c_write(TCN75_CONFIG_REG_ADDR);
 i2c_write(TCN75_CONFIG_VALUE);
 i2c_stop();
}

//-----------------------------------------
// Read the temperature and return the integer
// portion as a char.  The "1/2 degree" portion
// of the result is discarded and not returned.
// We don't need that level of precision.

char TCN75_read_temperature(void)
{
 char msb;
 char lsb;

 i2c_start();
 i2c_write(TCN75_I2C_WRITE_ADDR);
 i2c_write(TCN75_TEMP_REG_ADDR);
 i2c_start();
 i2c_write(TCN75_I2C_READ_ADDR);
 msb = i2c_read();   
 lsb = i2c_read(0);           
 i2c_stop();

 return(msb);
}

// end of program
Guest
Guest







reply
PostPosted: Mon Apr 19, 2004 5:45 pm     Reply with quote

thanks for your code. but the temp still jumps. Also if i use different chips. (also different address class)
what i2c pullups do you use?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 19, 2004 5:53 pm     Reply with quote

Quote:
what i2c pullups do you use?

I'm using 3.3K pullups, going to +3.3v.
(Vdd = +3.3v on this board).
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