View previous topic :: View next topic |
Author |
Message |
Bilal
Joined: 24 Apr 2010 Posts: 75 Location: Islamabad
|
i2c |
Posted: Thu Aug 05, 2010 8:39 am |
|
|
Hi. I am using pic16f877a and I have already utilised i2c pins (C3 and C4) with a EEPROM 24c256.
Now I want to use a real time IC DS1307.
My question is can I use any I/O pins for i2c protocol or can I only use one i2c supported device with my one PIC16f877a ? _________________ ... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19505
|
|
Posted: Thu Aug 05, 2010 8:54 am |
|
|
You can use other pins, using software I2C, but you can equally well just attach the RTC, to the same I2C bus you already have. This is why I2C devices have addresses. So long as they differ, there is nothing to stop you having half a dozen different I2C devices on the one bus. The DS1307, uses addresses 0xD0/D1 (using 8bit addressing), while a 24C256, will use 0xA?, with the '?', depending on the voltage pattern you have on the A0 to A2 pins. These will be quite happy to co-exist on one bus....
Best Wishes |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu Aug 05, 2010 11:50 am |
|
|
You can have multiple I2C busses on the same PIC BUT you should only use the hardware I2C if the PIC is acting as a Slave. The slave device needs the hardware I2C to recognise the address that the master is sending out. Software I2C for a slave gets way too messy and complicated.
I have a device that has a Master PIC that talks with multiple Slave PICs. Each slave PIC utilizes the hardware I2C port to talk to the master. Also, each slave PIC has a separate software I2C bus that bit-bangs a sensor. So, this PIC is using a hardware I2C and a software I2C. The slave just acts as a master when it's talking to the sensor.
Ronald |
|
|
Bilal
Joined: 24 Apr 2010 Posts: 75 Location: Islamabad
|
|
Posted: Fri Aug 06, 2010 5:45 am |
|
|
Thanks buddyd.
Ttelmah please can you tell me more about addresses. I can't understand fully. _________________ ... |
|
|
|