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

EEPROM and RTC on same I2C bus?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ivica



Joined: 15 Jul 2006
Posts: 2

View user's profile Send private message

EEPROM and RTC on same I2C bus?
PostPosted: Sat Jul 15, 2006 2:25 am     Reply with quote

Hello,

Does anyone have (positive Smile ) experience with EEPROM and RTC on same I2C bus?
As well, anyone who has used TMR module instead RTC?

Please help me about my dilema Confused .

Thank you
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: EEPROM and RTC on same I2C bus?
PostPosted: Sat Jul 15, 2006 3:33 am     Reply with quote

Ivica wrote:
Does anyone have (positive Smile ) experience with EEPROM and RTC on same I2C bus?


I use the DS1307 RTC with 24LC512 EEPROM in the same I2C bus without any problem.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Re: EEPROM and RTC on same I2C bus?
PostPosted: Sat Jul 15, 2006 1:06 pm     Reply with quote

asmallri wrote:
I use the DS1307 RTC with 24LC512 EEPROM in the same I2C bus without any problem.

Same thing. I used DS1307 RTC, two 24LC512 EEPROMs, and a MAX517 DAC on the same I2C bus. As long as you can make sure that each device on the bus has a unique address, your I2C bus will function.

Oh, there's one additional more subtle point. If you are going to use interrupts in the PIC, you can potentially end up in a situation like the following. Assume that PIC talks to some I2C devices in the in main(), and also talks to the other I2C devices in the ISR*. At some point main() starts an I2C transaction. Before main() ends the I2C transaction, and interrupt occurs and the ISR starts another I2C transaction on the same bus and clobbers the first transaction started by the main(). There are some methods, which allow avoiding situations like this:
1. All of the I2C communication should take place in the same priority level. I.e. all of the I2C code is in the ISRs or all of the I2C code is in the main().
2. Disable interrupts before starting the I2C transaction, and re-enable them after the I2C transaction is finished. You can do similar thing with flags and ifs without disabling interrupts.

-------------------
* ISRs should be made as short and as fast as practical. Typically serial communication in the ISR is not advised. However if the I2C clock rate is fast (100kHz+), hardware I2C is used, writing a couple of bytes on the I2C doesn't cause problems.
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Sat Jul 15, 2006 4:29 pm     Reply with quote

Check the addresses of all devices on the bus to make sure there is no conflict. For example, this can happen with the PCF8583 RTC and the 24LC256.

http://www.ccsinfo.com/forum/viewtopic.php?t=22136
Mark



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

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

PostPosted: Sun Jul 16, 2006 9:50 am     Reply with quote

DS1307 and AT24C32 on the same bus without problems. Are you having problems or just curious?
Ivica



Joined: 15 Jul 2006
Posts: 2

View user's profile Send private message

PostPosted: Sun Jul 16, 2006 7:42 pm     Reply with quote

Thanks for your answers guys, they kept me busy this weekend Smile

I am starting new project Mark. I have previous experience with Motorola/Freescale and SPI, and I have in my head information (from somewhere?) that some I2C EEPROMs and RTCs are difficult to be set on same bus.

Thanks again,
Ivica
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

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

PostPosted: Mon Jul 17, 2006 8:23 am     Reply with quote

It's only a few wires. Best to try it with the chips you want to use.
toxie



Joined: 22 Jun 2009
Posts: 6

View user's profile Send private message

PostPosted: Sun Jul 19, 2009 5:15 pm     Reply with quote

I`m having some issues with PCF8583 and ATMEL 24C16A on the same i2c bus.When i insert the eeprom the PCF resets itself to a value i`ve programmed in to it at start, it stops counting and the year is not properly set.When i take out the eeprom and restart the pic (16F690) everything works like a charm.I`ve tried to change the address of the 24C16A, but it`s the same :( .The PCF has the A0->Vdd in firmware it`s A2(write) , A3(read) .
Somebody had some similar problems ?
I`m using software i2c, the hardware i2c gives me all 00 .The pullups are 2k2,also tried 1k5, and around 4k it`s always the same.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 19, 2009 6:15 pm     Reply with quote

Quote:
I'm having some issues with PCF8583 and ATMEL 24C16A on the same i2c bus

What drivers are you using for the pcf8583 and AT24C16A ?
Provide a link or a directory path, if possible.


Quote:
The PCF has the A0->Vdd

What are the connections for A0, A1, A2 on the AT24C16A ?
toxie



Joined: 22 Jun 2009
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 3:21 am     Reply with quote

For the PCF8583 I'm using the driver from
http://www.ccsinfo.com/forum/viewtopic.php?t=27988

For the AT24C16A currently I have no driver. I will have to get it or to write on my own.
A0,A1,A2 are on Vss. I have put some jumpers on my board for easier address change, tried several combinations, but the same problem occurs.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 1:39 pm     Reply with quote

Quote:
When I insert the eeprom the PCF resets itself to a value I've
programmed in to it at start, it stops counting and the year is not
properly set.

Post your test program. Don't post the PCF8583 driver. Just #include it
in your test program. The program should be short, and compilable.

Also post your compiler version.
toxie



Joined: 22 Jun 2009
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 2:15 pm     Reply with quote

Version 4.016

Here is the code.I`ve stripped the main code only to test the PCF8583 and to be short as You said.The problem still occurs in the presence of the AT24C16A.
Code:

//#include <main.h>
#include <16F690.h>
#define PCF8583_SDA  PIN_B4 /*PCF8583 SDA*/
      #define PCF8583_SCL  PIN_B6 /*PCF8583 SCL*/
      #define PCF8583_WRITE_ADDRESS 0xA2
      #define PCF8583_READ_ADDRESS  0xA3
#use delay(clock=18432000)
#use rs232(baud=4800,parity=N,xmit=PIN_B7,rcv=PIN_B5,bits=8)
#use i2c(Master,sda=PIN_B4,scl=PIN_B6)
#FUSES HS            //External RC Osc#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOCPD                    //No EE protection
#FUSES NOPUT                    //No Power Up Timer
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled

unsigned int1 state=0;
unsigned char get_time=4;
unsigned char counter=0;

//-------- PCF8583 START --------//

#include <pcf8583.c>
date_time_t dt;

//--------- PCF8583 END ---------//

#int_RTCC
void RTCC_isr()
{
   counter++;
   if (counter==250)
   {
      state=!state;
      output_bit(PIN_C2,state);
      get_time--;
      counter=0;

   }

}


void main()


{
   setup_oscillator(OSC_NORMAL);
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);
delay_ms(1000);   

        dt.day     = 30;    // 30
     dt.month   = 11;    // November     
     dt.year    = 9;    // 2009
      dt.hours   = 13;    // 23 hours (11pm in 24-hour time)
      dt.minutes = 52;    // 59 minutes
      dt.seconds = 50;    // 50 seconds
      dt.weekday = 0;     // 0 = Sunday, 1 = Monday, etc.

PCF8583_init();


      PCF8583_set_datetime(&dt);       
      delay_ms(500);   
      printf("\n\r");
      printf("New date/time written to PCF8583.\n\r");

delay_ms(5000);
   
printf("year value %u",dt.year);

while(1)
   {

if (!get_time){
delay_ms(100);   
   PCF8583_read_datetime(&dt);   
delay_ms(300);   
   printf("| %u/%u/%02u, %u:%02u:%02u\n\r\n\r",
           dt.day, dt.month, dt.year,
           dt.hours, dt.minutes, dt.seconds);
get_time=4;
}

}

}


mskala



Joined: 06 Mar 2007
Posts: 100
Location: Massachusetts, USA

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 2:27 pm     Reply with quote

Also, from a general hardware point of view, as you add devices to the I2C
bus, increasing the total capacitance, you may need to adjust the pullup
resistor values.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 2:30 pm     Reply with quote

Quote:
enable_interrupts(INT_RTCC);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);

You have INT_EXT enabled, but you don't have an isr for it. Delete that
line.

Once that is fixed, test it, and post the answers to these questions:

1. Does the problem occurs if the eeprom is simply plugged into its socket
while using the program shown above ?

2. Does the eeprom have +5v and ground connected to its Vdd and Vss pins ?

3. What are the values of the pull-up resistors on SDA and SCL lines ?

4. Are you sure that you didn't accidently swap the wires going to SDA
and SCL on the eeprom ? (ie., are they going to the incorrect pins ?)

5. Have you tried different addresses on the eeprom (jumpered with
A0,A1,A2 pins) ?
toxie



Joined: 22 Jun 2009
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 2:44 pm     Reply with quote

I commented the the line with external interrupt. I have to mention that I need the external interrupt in my program. But for the test it`s commented out.

1.Yes the problem occurs when i plug the eeprom in.
2.Yes.
3.The values of the pullup resistors, were 1k5, 2k2, 4k7, and now it`s 10k.
4.I`ve double checked the lines. It goes from the pic to eeprom, from eeprom to pcf8583
5.Yes. I`ve tried. Currently it`s A0->0 A1->0 A2->1
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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