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

24LC256 on I2C Bus with MAX6900 .. errors :(

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



Joined: 14 Jan 2004
Posts: 88
Location: Aurora, Ontario, Canada

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

24LC256 on I2C Bus with MAX6900 .. errors :(
PostPosted: Mon Apr 26, 2004 2:57 pm     Reply with quote

Hi.

I have an 18F6620 hooked up with two PIC 24LC256's and a MAX6900 RTC on the hardware I2C bus. All are on seperate ID's and do work somewhat.
I can read and set the time from the Max6900, and I can write and read the eeprom, BUT:

Every time I write some data to the eeprom, it ignores the first character written to it, and when reading, it reads 0xFF for that same first character

E.G.

Code:

void Write_VendorHelp(void) {
long int i;
VendorDescriptionLength,1); // passing a pointer to the receivebuffer to the I2C Page write function

for(i=0;i<(VendorDescriptionLength -1);i++) {
write_ext_eeprom(i+VendorBaseAddress,ReceiveBuffer[i+1]);
}// end for

}


yes.. the ReceiveBuffer contains the right data, I can even send it to the serial port for verification, but the first character is always missing.
If I take the MAX6900 off teh board, then it works fine, so it is a conflict between the two..
The opposite problem is also present when reading from the 24LC256, again also solved by taking the MAX6900 out of the circuit.


Code:


void GET_VendorHelp(void){
int i;
for(i=0;i<(VendorDescriptionLength -1);i++) {
    fprintf(PORT2,"%c",read_ext_eeprom(i+VendorBaseAddress));   
}// end for




Now even though I am tempted to leave it out all together, my boss seems to think that we need a RTC and he picked the MAX6900..... yay

Any suggestions for what could be wrong?... I have 2K2 pullups on the I2C bus, is that good enough for 3 I2C devices?

Thanks in advance

Kasper

MPLAB 6.4, PCWH 3.189, WinXP Pro, SP1, ICD2
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 26, 2004 3:32 pm     Reply with quote

Whenever I see something like this, my instant first thought is
that you're not doing a NACK on the last i2c read.
Kasper



Joined: 14 Jan 2004
Posts: 88
Location: Aurora, Ontario, Canada

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

PostPosted: Mon Apr 26, 2004 4:16 pm     Reply with quote

PCM programmer wrote:
Whenever I see something like this, my instant first thought is
that you're not doing a NACK on the last i2c read.


Thanks Smile
Needless to say, you were right Very Happy

The code below shows where I changed the read function

So, slightly off topic, should the value of the pullup resistors change, depending on how many devices are on the bus, and in that case, what is a good value for 2x 24LC256 and 1x MAX6900 ?

Code:


void Get_Time_MAX6900(void) {

   output_float(eeprom_scl);
   output_float(eeprom_sda);
   delay_us(4);

// in burst mode, the MAX6900 does not read the century byte.
     i2c_start();
     i2c_write(0xA0);
     i2c_write(0xBF);
     i2c_start();
     i2c_write(0xA1);
    Second =  i2c_READ();
    Minute =  i2c_READ();
    hour   =  i2c_READ();
    Date   =  i2c_READ();   
    Month  =  i2c_READ();
    Day    =  i2c_READ();   
    Year   =  i2c_READ();
//    RTCcontrol=  i2c_READ(1);
    RTCcontrol=  i2c_READ(0);
     i2c_stop();
    delay_ms(3); // after any read or write operation, do not talk to it for 2.5ms
   Century= 32; ///20Hex .. reading the century seems to be screwy.. so it is not year 2100 compatible :o\
//fprintf(PORT2,"\rControlReg:=[%X]",RTCcontrol);
}

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 26, 2004 5:05 pm     Reply with quote

Quote:
So, slightly off topic, should the value of the pullup resistors
change, depending on how many devices are on the bus, and in that
case, what is a good value for 2x 24LC256 and 1x MAX6900 ?

According to the data sheets for those chips and the PIC, the
maximum capacitance per pin is 10 pf. So 4 pins x 10 pf = 40 pf max.

Based on the charts in the i2c spec, for 5v operation at 100 KHz clock
speed, you could use a value between roughly 1.6K and 20K.
So if you want to be on the safe side, and don't care about power
consumption, you could use 2.2K. Or, 4.7K.
Kasper



Joined: 14 Jan 2004
Posts: 88
Location: Aurora, Ontario, Canada

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

PostPosted: Tue Apr 27, 2004 8:07 am     Reply with quote

PCM programmer wrote:
Quote:
So, slightly off topic, should the value of the pullup resistors
change, depending on how many devices are on the bus, and in that
case, what is a good value for 2x 24LC256 and 1x MAX6900 ?

According to the data sheets for those chips and the PIC, the
maximum capacitance per pin is 10 pf. So 4 pins x 10 pf = 40 pf max.

Based on the charts in the i2c spec, for 5v operation at 100 KHz clock
speed, you could use a value between roughly 1.6K and 20K.
So if you want to be on the safe side, and don't care about power
consumption, you could use 2.2K. Or, 4.7K.



Thanks again.. You are really a valuable asset here Smile
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