PDA

View Full Version : Using Multiple EEPROMs



Tom Gonser
- 19th March 2005, 15:56
I have seen/used simple examples of using a single external EEPROM, and know that these can be chained together, but have not seen any posts on the subject, I want to check my thinking with those who know here..

I have two 24LC515 512kbit chips, and want to use them to store data for a logger. The object of the device is to log inbound data in 35bit long data points, coming in one per second. At 512kb this is roughly 30 minutes of storage, at 1Mbit it is 1 hour, and I need an hour.

Question is, HOW to address two/more of these devices? The MCP data sheets discuss the addressing works, but PBP does not address the 'Chip Select Bits' deeply enough for me to really grock it.

Control bits for this unit is '1010'.

Next bit is 'block select bit' - which does not sound like I need to address.(?)

The two are 'Chip Select Bits' - which "Must correspond with the A0 and A1 logic levels' - so I assume that means tying these two pins high or low physically on the board (right?), for example:

Chip 1 - A0=VCC, A1=VDD
Chip 2 - A0=VCC, A1=VCC
Chip 3 - A0=VDD, A1=VCC
Chip 4 - A0=VDD, A1=VDD

So I can see how the system might tell the chips apart based on this.

I THINK the way to do this must be to format Symbols for these different chips?

symbol chip1 = %1010x01x ' what is 4th and 1st value supposed to be?
symbol chip2 = %1010x00x ' what is 4th and 1st value supposed to be?

then when writing to these, the appropriate chip would respond.. ie, if chip 2 sees the chip select as '00' it responds, and chip 1 ignores. (Right?)

SO.. Physically -- are the pins of SDA, SCL, VDD, and VCC tied together on these chips??

Sorry for the rambling questions.. I hope someone can shed some light on things:

1. What is the proper setup for multiple chips ; %1010x01x ?? or what?
2. Are the external eeproms physically tied on pins A0 and A1 to set their address?
3. Do they all share the same bus lines?
4. What is the PBP command setup for dealing with multiple units? Does my program logic deal with EACH CHIP, or does PBP make both of them into one big memory bank, and I don't have to worry about the two units?
5. If Do have to worry about the two units then I need to be intelligent about using one up, then jumping to the other, then remembering where I put things when I go to get them back.... Right?

Thanks!

Tom

NavMicroSystems
- 19th March 2005, 17:27
1. What is the proper setup for multiple chips ; %1010x01x ?? or what?

I use the 24FC512 because you can have up to 8 devices on the same bus.
The 515 is a bit different,
I'll have a look at the datasheet and get back to you later



2. Are the external eeproms physically tied on pins A0 and A1 to set their address?

The answer is: YES



3. Do they all share the same bus lines?

The answer is: YES



4. What is the PBP command setup for dealing with multiple units? Does my program logic deal with EACH CHIP, or does PBP make both of them into one big memory bank, and I don't have to worry about the two units?

You can only access one physical chip at a time by specifying it's address with I2CWRITE / I2CREAD



5. If Do have to worry about the two units then I need to be intelligent about using one up, then jumping to the other, then remembering where I put things when I go to get them back.... Right?


You would need some pointer anyway to memorize which location you have last written to.

Have a look at this thread (http://www.picbasic.co.uk/forum/showthread.php?t=1178&highlight=eeprom+reducing)

Tom Gonser
- 19th March 2005, 21:06
THANKS MUCH!!

I am glad I was on the right track. Do you know of any higher density memory that can be used like this? I'd really like 2-4m per chip if it existed, was easy to write to using PBP, and was not to horribly expensive..

Tom

Tom Gonser
- 19th March 2005, 22:39
OK - I have the EEPROMS setup per what has been described, and we can compile and it LOOKS like it sends data to the chips, but I cant' see anything coming back.. I read in 1000 values from 0 to 999 in an 'x' loop, then read them back, and all I see are '0's... Help! I think my naming of the chips is wrong..

Chip is an 16F876A.

I have two chips 24LC515 512k .. I have given them names:

DPIN var PortA.2 ' I2C data
CPIN var PortA.1 ' I2C clock
address var byte
value var byte

Chip1 con %10100000 ' address of chip1
Chip2 con %10100100 ' address of chip2

Init:
PORTA = %00000 'Initialize PortA to all zeros - all output
TRISA = %00000 'All port A output
PORTB = %00000101 'Initialize PortB - port 2 for data, port 0 for button interrupt
TRISB = %00000101 'Port 2 inputs are 0 and 2
T1CON = %01000000 'Timer1 1:1 prescale(?). Timer1 off
----------------------------------------------------------------------

I read and write to them like this: For this demo I only will write 1000 records in each chip.


storedata:
for x = 0 to 1000
i2cwrite dpin,cpin,chip1,x,x
pause 10
serout2 Apinout, 16468, [I,CLR]
serout2 Apinout, 16468, [I,L1_C1]
serout2 Apinout, 16468, ["Writing: C1 ",#x]
Next x

for x = 0 to 1000
i2cwrite dpin,cpin,chip2,x,x
pause 10
serout2 Apinout, 16468, [I,CLR]
serout2 Apinout, 16468, [I,L1_C1]
serout2 Apinout, 16468, ["Writing: C2 ",#x]
Next x

...
...
Readitback:
' read memory contents to screen.
serout2 Apinout, 16468, [I,CLR]
serout2 Apinout, 16468,[I,L1_C1]
Serout2 AGPSout, 16572, ["Memory Dump Chip 1: ", 10,13]
Address =0
p=0
x=0
For p = 1 to 29 ' total sentences storable in memory
serout2 AGPSout, 16572, ["SS ",#p,": "]
for address = X to (X+34)
I2Cread Dpin,Cpin,Chip1, address, value
serout2 AGPSout, 16572, [",",#value]
next address
serout2 AGPSout, 16572, [10,13]
X=X+34
next p

serout2 Apinout, 16468, [I,CLR]
serout2 Apinout, 16468,[I,L1_C1]
Serout2 AGPSout, 16572, ["Memory Dump Chip 2: ", 10,13]
Address =0
p=0
x=0
For p = 1 to 29 ' total sentences storable in 1k
serout2 AGPSout, 16572, ["SS ",#p,": "]
for address = X to (X+34)
I2Cread Dpin,Cpin,Chip2, address, value
serout2 AGPSout, 16572, [",",#value]
next address
serout2 AGPSout, 16572, [10,13]
X=X+34
next p

Return

mister_e
- 21st March 2005, 17:11
fast overlook... did you read caefully your EEPROM datasheet??? Try to use a WORD sized variable for your address.. also look how many bits must be shift for address + control word and how.

Tom Gonser
- 27th March 2005, 07:37
Working now... It was simply a mis-wired A2 pin. With everything neatly in place, resistors in line, etc. We have both chips working fine. I was also off in the chip 2 definitin by a bit. Now it works great. Thanks for the help!

Chip1 con %10100000 ' address of chip1
Chip2 con %10100010 ' address of chip2

TG