View previous topic :: View next topic |
Author |
Message |
Analyzer
Joined: 07 Sep 2003 Posts: 32
|
How to Connect More than 1 Eeprom |
Posted: Tue Dec 23, 2003 4:07 pm |
|
|
Hi there,
I would like to connect 2 24LC256 the same line.But i have no experience about this subject.I read datasheet of 24LC256 a lot of times but no valuable thing in it.Is there any schematic and ccs code for it? I'm using one 24LC256 without any problem.I need every help.
Thanks in advance.
Analyzer |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Tue Dec 23, 2003 4:29 pm |
|
|
Well, hear ye the words of the Microchip web site:
The 24LC256 is a 32K x 8 (256K-bit) Serial Electrically Erasable PROM memory with an I2C™ compatible 2-wire serial interface bus. The 24LC256 features a page-write capability of up to 64 bytes of data and is capable of both random and sequential reads up to the 256K boundary. Functional address lines that allow up to eight devices on the same bus for up to 2M bit address space. The 24LC256 is capable of operation across a broad voltage range (2.5V to 5.5V) and extended/automotive temperature range (-40°C to +125°C) with a maximum clock frequency of 400kHz. This device was developed for advanced, low-power applications such as personal communications or data acquisition. The 24LC256 is available in standard 8-pin PDIP and 8-pin SOIC (208 mil), packages.
Note the part about "functional address lines". It seems as though what you'd do would be to wire all the chips in parallel as far as the I2C bus is concerned, and set up an address hard-wired to the 3 pins of each chip, so each chip gets a unique set of inputs. Then data coming from the PIC as part of the I2C transaction would select one chip and cause only that EEPROM to respond. I think that's right. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Dec 23, 2003 7:56 pm |
|
|
Yep, the standard address is 0xA0. Setting the address 0 line high will give you 0xA2. Therefore, to talk to the second eeprom, use address 0xA2. |
|
|
Analyzer
Joined: 07 Sep 2003 Posts: 32
|
|
Posted: Wed Dec 24, 2003 2:24 am |
|
|
Hmm,
I can understand how to address memory but i'm still confused how to connect two or more i2c mems.Is there any schematic design around here?
Analyzer. |
|
|
Charlie U
Joined: 09 Sep 2003 Posts: 183 Location: Somewhere under water in the Great Lakes
|
I2C addressing |
Posted: Wed Dec 24, 2003 9:41 am |
|
|
Since it sounds as though you currently have one device connected, you must be aware that pins 1, 2, and 3 are tied to ground. The binary pattern of these pins creates the address of the device on the I2C bus. Pin 4 which is the device ground is also tied to ground. Pins 5 and 6 are the I2C interface, 7 is the Write Protect, which can be left open since it has internal pull down, and pin 8 is the supply.
To connect a second device to your processor, connect the power pins to ground and the supply, connect the I2C interface of the device to the I2C of the first device and processor, leave pin 7 (WP) open, then tie pin 1 high either directly or though a resistor (say about 4.7k or 10k), then tie pins 2 and 3 to ground.
Then, as Mark replied above, use 0xA0 in the device address of the I2C message to read and write to the first device as you have been, and use 0xA2 in the device address of the I2C message to read and write to the second device. This is detailed in section 5 of the data sheet. |
|
|
Analyzer
Joined: 07 Sep 2003 Posts: 32
|
|
Posted: Wed Dec 24, 2003 2:06 pm |
|
|
Thank you for your reply.Let me check if i understand it correctly.
I have 2 memory and a 877. I connect first mem's SCK and second mem's SCK to RB0 and 1st mem's SDA and 2nd SDA to RB1.1st mem's A0,A1,A2 ports connected to GND.2nd mem's A1,A2 ports connected to GND, A0 port to 10k res, other pin of res to +5V.Finally i add pull-up resistors to SDA and SCK lines.
Is it true?
I drawed it but i have no place to upload.Sorry.
Analyzer. |
|
|
Charlie U
Joined: 09 Sep 2003 Posts: 183 Location: Somewhere under water in the Great Lakes
|
More I2C |
Posted: Wed Dec 24, 2003 2:51 pm |
|
|
That sounds correct to me, as long as you understand that the I2C interface will be done with software and not hardware. If you want to use the hardware features, then SCL must be connected to RC3 and SDA must be connected to RC4. Also include the #use directive for the I2C interface: #use I2C(master, scl=pin_c3, sda=pin_c4, slow, force_hw) which will use the hardware pins and force the hardware implementation. Slow indicates that the connected devices are limited to the slow I2C spec which I thinks is 400kHz. |
|
|
Analyzer
Joined: 07 Sep 2003 Posts: 32
|
|
Posted: Wed Dec 24, 2003 3:50 pm |
|
|
Hai again,
I connected my memories as above and i tested this schematic with this code :
#include "c:\.....\I2C_Mem.h"
#include <24128.c>
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
void main() {
int16 c,i,s;
init_ext_eeprom();
c = 1;i=50;
s=32000;
printf("WRITE\n\r");
while(c < 100) {WRITE_EXT_EEPROM(c+s,i);c++;i++;if (i>100) i=50;}
c = 1;i=50;
printf("READ\n\r");
while(c < 100) {printf("%c",READ_EXT_EEPROM(c+s));c++;i++;if (i>100) {i=50;printf("\n\r");}}
printf("\n\rFinished");
}
I missed something with addresses i think, and i have no idea how to talk with first and second memory.. This code works if 0<s<32676 So, i think i can not access to the second memory. I'm closing to finish
Analyzer. |
|
|
|