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

i2c library - help!!

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



Joined: 24 May 2006
Posts: 6
Location: S㯠Paulo - Brazil

View user's profile Send private message

i2c library - help!!
PostPosted: Wed May 24, 2006 6:45 pm     Reply with quote

Hi!
I am with one pic 16F877 and a memory 24C04.
I am using the CCS and the library i2c to ready/write the memory.
I change it and I tried to make some changes, I am using the AN10216_1 of the Philips, that deals with i2c - http://www.semiconductors.philips.com/acrobat_download/applicationnotes/AN10216_1.pdf
I tried to make a reading of the memory using the described sequencia in this AN (inside of the document one exists slide number 35), but dont work correct.
I only obtain to make the reading using the code of the CCS. The code of ccs is:

////////////////////////////////////////////

byte read_ext_DEVICE(long int address)
{
byte data;
i2c_start();
i2c_write(ENDERECO); // 0xA0

i2c_write(address);
i2c_start();
i2c_write(ENDERECO+1);
data=i2c_read(0);
i2c_stop();
return(data);

/////////////////////////////////////

And my code is:

///////////////////////////////////////
byte read_ext_DEVICE(long int address)
{
byte data;
i2c_start();
i2c_write(ENDERECO+1);
i2c_write(address);
data=i2c_read(0);
i2c_stop();
return(data);
///////////////////////////////////////////



In the library of ccs I have that to call the address memory (0xA0) + 0, that would be for writing (write) and in sequence a read command.
Somebody can explain pq to me this?
[ ]'s
Marcelo
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 24, 2006 7:42 pm     Reply with quote

Don't use the Philips appnote. Use the actual data sheet for the 24C04.

Here is a link to the data sheet for the Microchip 24LC04B:
http://ww1.microchip.com/downloads/en/DeviceDoc/21708E.pdf
Look at the diagram for "Random Read" on page 10. It matches
the CCS driver code.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu May 25, 2006 7:12 am     Reply with quote

The CCS driver works. Why are you changing it? Did you try it? Remember that you need to have pullups on the clock and data lines.
marceleza



Joined: 24 May 2006
Posts: 6
Location: S㯠Paulo - Brazil

View user's profile Send private message

PostPosted: Mon May 29, 2006 5:35 am     Reply with quote

Hi!

Thanks for the aid!
Yes, the code of ccs works fine, I were only curious why in a AN of philips, the way of reading it is deferential of that it is in the example of ccs.
But I saw that the routine that I modified he only serves to read the position of following memory, or either, if I will be in position 00, the reading I will be of position 01.

[]´s

Marcelo
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