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

multi 24lc128s

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



Joined: 13 Oct 2003
Posts: 32

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

multi 24lc128s
PostPosted: Tue Sep 18, 2012 2:30 am     Reply with quote

Hi

I recently upgraded my compiler to version 4.135 and now I have a problem. (Please don't ask how old the previous version was - you will be horrified - it goes back to one of the early 3 versions).

I have a card that has a pic 16f877a, a ds1307 and a 24lc128.
This is connected to a plug in card that has a 16f877a and two 24lc128s.

Since upgrading the compiler version, the data being read on the first card is sometimes corrupt. Sometimes it reads correctly and other times not.
I have found that if the second 16f877a is not plugged in, it correctly reads all the time.
What would be causing this?

I have tried setting it to multi master - makes no difference.
I know the hardware is right, because I have been using the hardware for the 15 years or so.

My code for reading the 128 is as follows - I have taken this from the example file, and have also changed it to the newer version as the one I was ready was a lot different.

I also tried the version that checks to see if the device is ready and that didn't work either.

Code:

#define EE_SDA  PIN_C4
#define EE_SCL  PIN_C3

#define hi(x)  (*((int8 *)&x+1))
#use i2c(multi_master, sda=EE_SDA, scl=EE_SCL)
#define EEPROM_ADDRESS long int
#define EEPROM_SIZE    16384

void init_ext_eeprom()
{
   output_float(EE_SCL);
   output_float(EE_SDA);
}

void write_ext_eeprom(long int address, BYTE data)
{
   short int status;
   i2c_start();
   i2c_write(eepromaddress);
   i2c_write(address>>8);
   i2c_write(address);
   i2c_write(data);
   i2c_stop();
   i2c_start();
   status=i2c_write(eepromaddress);
   while(status==1)
   {
      i2c_start();
      status=i2c_write(eepromaddress);
   }
   i2c_stop();
}

BYTE read_ext_eeprom(long int address)
{
   BYTE data;
   i2c_start();
   i2c_write(eepromaddress);
   i2c_write(address>>8);
   i2c_write(address);
   i2c_start();
   i2c_write(eepromaddress + 1);
   data=i2c_read(0);
   i2c_stop();
   return(data);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 18, 2012 12:44 pm     Reply with quote

Quote:
I have a card that has a pic 16f877a, a ds1307 and a 24lc128.
This is connected to a plug in card that has a 16f877a and two 24lc128s.

I assume this means you have the i2c bus on each board is connected
to the to other board, so it's one big i2c bus ?

That means you have two PIC masters on the same bus. What prevents
both the PICs from trying to access the bus at the same time ? Because
if they do, you will surely get errors.

Also, if you connect these two independent boards together, what's the
combined equivalent resistance for the pull-up resistors now ? And what's
the speed of your i2c bus clock ? Post your #use delay() statements
and your #use i2c() statements.
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