PDA

View Full Version : Double eeprom 24LC64



chip_select
- 26th March 2008, 01:06
Hi, I have a small problem...Programming one 24LC64 with a 16f84a is everything ok but two 24LC64 in series on the same bus it doesn't work me.
Following the 24LC64 datasheet indications, to make you to work needs to put to +5 a pin or various combinations up to form at the most a group from 8 eeproms, I have chosen the A0 and street software, if I have understood well, modified the second eeprom to 1 the 2° right bit, in practice:

"I skip the whole code before and later for simplicity"
-----------------------------------------------
WRITING:
FOR I = 0 TO 10
ADDR = THE: _WRITE = THE: ADDR2 = THE: _WRITE2 = THE
I2CWRITE SDA, SCL,% 10100000, ADDR, [_WRITE] 'First EEPROM
Breaks 10
I2CWRITE SDA, SCL,% 10100010, ADDR2, [_WRITE2] 'Second EEPROM
Breaks 10
_WRITE2 = _WRITE2 * 3
GOSUB LETTURA
NEXT I
-----------------------------------------------
Where is the error?
Thanks
chip_x

mister_e
- 26th March 2008, 02:22
obviously you don't use Melabs PicBasic.... or the Breaks 10 is part of your comments?

You should have a PAUSE 10-50 after each I2CWRITE

Maybe a copy/paste error... but there shouldn't be any space between % and the ControlByte value in your I2CWRITE lines. I suggest you to use Constant variable instead.

ADDRx variable have to be WORD sized one.

When you say it doesn't work.. you mean? If you remove the first EEPROM, will the second one work? Same thing if you remove the second one, will the first one work? If so, you should reduce the Pull-up resistors. Usually 1.8K work in most cases.

chip_select
- 26th March 2008, 09:07
Hi Steve, "breaks" it is an error of copy. It is "pause 10." The space "% "there is not. ADDR is "word."
I use the PicBasic 2.50.
You as you would resolve the problem? Do I want to say as you write the code to identify the second eeprom on the same bus?
The first eeprom works.
thx
chip_s

mister_e
- 26th March 2008, 14:00
Maybe you'll find some good info at the following
http://www.picbasic.co.uk/forum/showthread.php?t=1453&

Just make sure your pull-ups are ~=1.8K
all EEPROMs A<2:0> pins goes somewhere
all EEPROMs WP pins are connected to GND, and it should work.

I just tried something like this with a 16F88 and 2 X 24LC64

<font color="#000000"> <font color="#000080">ASM
LIST W=-207
cfg1 = _INTRC_IO &amp; _WDT_OFF &amp; _PWRTE_ON &amp; _MCLR_ON &amp; _BODEN_ON &amp; _LVP_OFF &amp; _CCP1_RB0
cfg2 = _CP_OFF &amp; _CPD_OFF &amp; _WRT_PROTECT_OFF &amp; _DEBUG_OFF

__CONFIG _CONFIG1, cfg1 &amp; cfg2</font>

<font color="#008000">; Program Configuration Register 2
</font><font color="#000080">__CONFIG _CONFIG2, _IESO_OFF &amp; _FCMEN_OFF
ENDASM

</font>OSCCON=%01110000 <font color="#008000">' 8mhZ
</font><font color="#000080">DEFINE </font>OSC 8

PORTA = 0
PORTB = 0
TRISB = 0
TRISA = 0
ANSEL = 0
CMCON = 7

<font color="#000080">DEFINE </font>HSER_RCSTA 90h <font color="#008000">' Enable serial port &amp; continuous receive
</font><font color="#000080">DEFINE </font>HSER_TXSTA 20h <font color="#008000">' Enable transmit, BRGH = 0
</font><font color="#000080">DEFINE </font>HSER_SPBRG 12 <font color="#008000">' 9600 Baud @ 8MHz, 0.16%
</font><font color="#000080">DEFINE </font>HSER_CLROERR 1 <font color="#008000">' Clear overflow automatically

</font>SCL <font color="#000080">VAR </font>PORTB.0
SDA <font color="#000080">VAR </font>PORTB.1

EEP1 <font color="#000080">CON </font>%10100000 <font color="#008000">' First EEPROM A&lt;2:0&gt;=Gnd
</font>EEP2 <font color="#000080">CON </font>%10100010 <font color="#008000">' Second EEPROM, A&lt;2:1&gt;=Gnd, A0=Vcc

</font>Addr <font color="#000080">VAR WORD
</font>ByteA <font color="#000080">VAR BYTE
</font>ByteB <font color="#000080">VAR BYTE

PAUSE </font>50

<font color="#000080">HSEROUT </font>[&quot;Programming...&quot;,13,10]
<font color="#000080">FOR </font>Addr=0 <font color="#000080">TO </font>10
ByteA=Addr
<font color="#000080">I2CWRITE </font>SDA,SCL,EEP1,Addr,[ByteA]
<font color="#000080">PAUSE </font>10

ByteA=Addr+20
<font color="#000080">I2CWRITE </font>SDA,SCL,EEP2,Addr,[ByteA]
<font color="#000080">PAUSE </font>10
<font color="#000080">NEXT

HSEROUT </font>[&quot;ADDR EEP1 EEP2&quot;, 13,10]
<font color="#000080">FOR </font>Addr=0 <font color="#000080">TO </font>10
<font color="#000080">I2CREAD </font>SDA,SCL,EEP1,Addr,[ByteA]
<font color="#000080">I2CREAD </font>SDA,SCL,EEP2,Addr,[ByteB]
<font color="#000080">HSEROUT </font>[<font color="#000080">DEC </font>Addr,&quot; &quot;,_
<font color="#000080">DEC </font>ByteA,&quot; &quot;,_
<font color="#000080">DEC </font>ByteB,13,10]
<font color="#000080">NEXT

</font>@ <font color="#000080">GOTO </font>$

and the output is...

Programming...
ADDR EEP1 EEP2
0 0 20
1 1 21
2 2 22
3 3 23
4 4 24
5 5 25
6 6 26
7 7 27
8 8 28
9 9 29
10 10 30

chip_select
- 26th March 2008, 19:32
Hi, I have used, for the data and the clock 2 resistors from 4.7k.
I have tried to complile your program and me from an error:

Error[118] c:\eeprom\16f88.asm 70: Overwriting previous address contents(2007)


chip_s

mister_e
- 26th March 2008, 19:38
Well, that's easy to fix once you know how to and why. The following link will teach it to you. Read at least POST#1 to 5.

Presetting Configuration Fuses (PIC Defines) into your Program
http://www.picbasic.co.uk/forum/showthread.php?t=543

chip_select
- 27th March 2008, 07:51
Thanks mister_e you have been me of great help. Hi and good day.
chip_x