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

LM75A and i2c

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



Joined: 13 Sep 2005
Posts: 4

View user's profile Send private message

LM75A and i2c
PostPosted: Tue Sep 13, 2005 11:21 pm     Reply with quote

Hi people!
I'm trying to put to work an LM75A and a 16F88.
My problem is that I have realized that i don't know anything about the i2c implementation of CCS.

In the datasheet of LM75A is stated that the default register is the TEMP reg, that contains the 16 bit's to read (11 actually).
So, I hard wired the address pins to 0, then the address must be 72 decimal (1001 is hard wired in the chip).
Back to C code, I wrote:

i2c_start(1);
i2c_write(72);
data1 = i2c_read();
delay_ms(100);

data2 = i2c_read(0);
delay_ms(100);

i2c_stop();

Ok, the delay's are simple especulation...

The values in data are always 255 decimal...
Any help?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 13, 2005 11:34 pm     Reply with quote

Here is a report from Philips that says the LM75A can replace the TCN75:
http://www.standardics.philips.com/products/i2cthermal/pdf/philips_lm75a_vs_microchip_tcn75.pdf

There is a driver for TCN75 at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=19061&highlight=tcn75
Ttelmah
Guest







PostPosted: Wed Sep 14, 2005 4:09 am     Reply with quote

One obvious comment though on the attempt posted. The address byte sent, also contains the data direction flag as the bottom bit. An 'even' address, will imply a data write, not a data read. An address needs to have one added, to enable reading.
It might well work with the address set to 73.

Best Wishes
Barney



Joined: 18 Oct 2004
Posts: 41
Location: Newark, CA

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 2:35 pm     Reply with quote

I found the CCS I2C routines very easy to use. I used a 16F88 to get temperature info from a AD7614 using the following routine:

Code:

  addr = 0x90 | (snsr_addr << 1);//build 7 bit address
  addr |= 0x01;                  //set read bit
  i2c_start();
  i2c_write(addr);
  high = i2c_read();
  low = i2c_read(0);
  i2c_stop();


All I2C parts have a 7 bit address and for the AD7416 the first 4 bits are 0101 (ie 0x90). The AD7614 has a 3 bit address range so snsr_addr is the address (0 thru 7) of the chip I want. The address LSB is the read/write direction flag. There are two reads because the chip returns two bytes of temperature data.

My biggest problem with I2C is remembering to put in the pull up resistor.
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