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 PIC16F876 PCF8583 24C16 - Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
H. Schleyer
Guest







I2C PIC16F876 PCF8583 24C16 - Problem
PostPosted: Wed May 08, 2002 1:41 am     Reply with quote

Hi PIC-folks,

I've trouble with reading the time of the 8583.
Address-Pin PCF8583 -> +5V
Address-Pins 24C16 -> GND (As I know: not connected internally, anyway)

I got wrong data when using read_pcf(4) (hours).
reading seconds ,days etc works fine!
Writing hours works, too.
Reading and writing EEProm: no problem.

Am I mad?

Here's the code:

#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3

//#endif

#use i2c(master,sda=EEPROM_SDA, scl=EEPROM_SCL)

#define EEPROM_ADDRESS long int
#define EEPROM_SIZE 2048


#define hi(x) (*(&x+1))

void init_ext_eeprom() {
output_float(eeprom_scl);
output_float(eeprom_sda);
}

#separate
void write_ext_eeprom(long int address, byte data) {

i2c_start();
i2c_write((0xa0|(byte)(address>>7))&0xfe);
i2c_write(address);
i2c_write(data);
i2c_stop();
delay_ms(11);
}

#separate
byte read_ext_eeprom(long int address) {
byte data;

i2c_start();
i2c_write((0xa0|(byte)(address>>7))&0xfe);
i2c_write(address);
i2c_start();
i2c_write((0xa0|(byte)(address>>7))|1);
data=i2c_read(0);
i2c_stop();
return(data);
}

#separate
void write_pcf(byte address, byte data)
{
i2c_start();
i2c_write(0xa2);
i2c_write(address);
i2c_write(data);
i2c_stop();
}

#separate
byte read_pcf(byte address)
{
byte data;
i2c_start();
i2c_write(0xa2);
i2c_write(address);
i2c_start();
i2c_write(0xa3);
data = i2c_read(0);
i2c_stop();
return(data);
}

Thanks for help!
___________________________
This message was ported from CCS's old forum
Original Post ID: 4226
johnpcunningham
Guest







Re: I2C PIC16F876 PCF8583 24C16 - Problem
PostPosted: Wed May 08, 2002 9:51 am     Reply with quote

Do you have pull-ups on the SDA and SCL lines? I wouls suggest something around 2.1K on each from my I2C experiences. I2C is sensitive to rise and fall times on some devices so the "hotter" pullup workes better.
___________________________
This message was ported from CCS's old forum
Original Post ID: 4235
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: I2C PIC16F876 PCF8583 24C16 - Problem
PostPosted: Wed May 08, 2002 3:00 pm     Reply with quote

<font face="Courier New" size=-1>:=I got wrong data when using read_pcf(4) (hours).
:=reading seconds ,days etc works fine!
:=Writing hours works, too.
-----------------------------------------------

Give us some examples of the failure.

ie., if you write 00, or 10, or 23, what do you read back ?
etc.

Note: The above numbers are intended to be in BCD format,
so you would actually write 0x00, 0x10, and 0x23 to
the hours register.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 4249
H. Schleyer
Guest







Re: I2C PIC16F876 PCF8583 24C16 - Problem
PostPosted: Tue May 14, 2002 12:57 am     Reply with quote

writing the time works. Reading is fine as long the hour is not changing. Then Hours are 00. (BCD, of course).
when I pull the 24C16 of socket, time reading is fine.
So I think it's something with addressing.



:=<font face="Courier New" size=-1>:=I got wrong data when using read_pcf(4) (hours).
:=:=reading seconds ,days etc works fine!
:=:=Writing hours works, too.
:=-----------------------------------------------
:=
:=Give us some examples of the failure.
:=
:=ie., if you write 00, or 10, or 23, what do you read back ?
:= etc.
:=
:=Note: The above numbers are intended to be in BCD format,
:= so you would actually write 0x00, 0x10, and 0x23 to
:= the hours register.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 4337
H. Schleyer
Guest







Re: I2C PIC16F876 PCF8583 24C16 - Problem
PostPosted: Tue May 14, 2002 1:00 am     Reply with quote

sure. tried 1k and 10k. same effect.

:=Do you have pull-ups on the SDA and SCL lines? I wouls suggest something around 2.1K on each from my I2C experiences. I2C is sensitive to rise and fall times on some devices so the "hotter" pullup workes better.
___________________________
This message was ported from CCS's old forum
Original Post ID: 4338
Guest








PostPosted: Fri Jan 06, 2006 9:02 am     Reply with quote

Give me an example how to write minutes and hours into 8583.
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