Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:45 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : EEPROM 24xx

Author Message
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 09:18pm 06 Feb 2012
Copy link to clipboard 
Print this post

Hi guys
Anybady has sample with read/write to 24c64? (Any 24xx)?
I did try many different way to do this' but with no sucess.
Please helpEdited by ztoti 2012-02-08
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 09:47pm 06 Feb 2012
Copy link to clipboard 
Print this post

Hi Ztoti

More information would help.

what address you are using
is your speed setting 400k
are you using I2C
schematic.
sample of your code.

regards Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 10:10pm 06 Feb 2012
Copy link to clipboard 
Print this post

Hi Bill,
The sample is below:
Complete=0
I2cen 100,1000,eprom
I2csend &h50,0,2,0,10 ' write 10 at memory address 0. Pin 1,2,3,4,7=GND
Do while complete<>1
Loop
Complete=0
If mm.i2c<>0 then
Print "error during sending";mm.i2c
Else
Print "send is complete"
Endif
,
,
,----- read location 0 --------------
I2crcv &h50,0,1,0,n
Pause 1000
Print n
End
'------ interrupt----------
I2cdis
Eprom:
Complete=1
Ireturn

Edited by ztoti 2012-02-08
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 12:03am 07 Feb 2012
Copy link to clipboard 
Print this post

I see you are using 100khz timming.
what is the supply to the EEprom 3.3 of 5v

It is recomended that the timming is 400khz for
5v supply -
I2Cen 400,1000

Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 07:37am 07 Feb 2012
Copy link to clipboard 
Print this post

'------ interrupt----------
I2cdis
Eprom:
Complete=1
Ireturn


If your I2cdis is important and I think it is, then it is in the wrong place as it will never get executed. When the interrupt at the end of the transfer is completed then execution flow will jump to the label Eprom:.Edited by BobD 2012-02-08
 
boss

Senior Member

Joined: 19/08/2011
Location: Canada
Posts: 268
Posted: 04:08pm 08 Feb 2012
Copy link to clipboard 
Print this post

Hi,

all kind of 24xxx eerom's need an extra time for write operation. You may found this in datasheet. In my case (AT24C32) time for complete "write op" is 10ms.

Regards
boss
------------------------------------------------------------ --------------------


I2cen 100,1000,eprom
I2csend &h50,0,2,0,10 ' write 10 at memory address 0. Pin 1,2,3,4,7=GND
Pause 10
I2cdis
If mm.i2c<>0 then
Print "error during sending";mm.i2c
Else
Print "send is complete"
Endif
 
boss

Senior Member

Joined: 19/08/2011
Location: Canada
Posts: 268
Posted: 04:26pm 08 Feb 2012
Copy link to clipboard 
Print this post

Hi ztoti,

here is an example:


Rem WRITE TO AT24C32
Dim RTCBUFF(4196)
I2CADDR=&H50 ' 24C32
K=&hAC
For J=&h0 To &hF
For I=&h0 To &hFF
I2CEN 100,100 'ENABLE I2C
I2CSEND I2CADDR, 0,3,J,I,k
I2CDIS
Pause 10
If MM.I2C <>0 Then Print "1=NAK 2=TIMEOUT"; MM.I2C,j,i:End:EndIf
'L=(j*256+I)
'Print "Byte ";L, " ";Chr$(13);
Next i: Next j
Print "ROM HAS BEEN WRITTEN with "; K

Regards
boss
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 07:33pm 08 Feb 2012
Copy link to clipboard 
Print this post

Thanks boss,
This is great examples but did you try to read from 24XX?
That is my bigest problem, how to read from any location.
If you have a solution please share it.
Thank you
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 12:25am 09 Feb 2012
Copy link to clipboard 
Print this post

You could try this to read from any location

I2CRCV I2Caddr, 0, DataLength, EEPROMdata(HI_addr * 256 + LO_addr), 1, HI_addr, LO_addr

where HI_addr ranges from 0x00 to 0x1F and LO_addr ranges from 0x00 to 0xFF to select the EEPROM address you wish to start reading from. If DataLength=1 then the EEPROMdata var does not need to be an array. The array index does not need to be the same as the address but it does make it less confusing.

This info from the datasheet. I don't (yet) have one of these devices.Edited by BobD 2012-02-10
 
boss

Senior Member

Joined: 19/08/2011
Location: Canada
Posts: 268
Posted: 05:00am 09 Feb 2012
Copy link to clipboard 
Print this post

Hi ztoti,

here is the exeample -enjoy it

Rem READ From AT24C32
Dim RTCBUFF(4196)
I2CADDR=&H50 ' 24C32
K=&hAC
Pause 10
For I=0 To 4095
RTCBUFF(I)=&H0
Next I
For J=&H0 To &HF
For I=&h0 To &hFF
L=(j*256+I)
I2CEN 100,100 'ENABLE I2C
I2CSEND I2CADDR, 0,2,J,I
I2CRCV I2CADDR, 0,1,RTCBUFF(L)
' Print "Read Byte "',L;Chr$(13);
I2CDIS
If MM.I2C <>0 Then Print "1=NAK 2=TIMEOUT"; MM.I2C,j,i:End:EndIf
Next I: Next J
For I=0 To 4095 Step 8
Print "Byte ";I;" ||";Hex$(RTCBUFF(I));"|";
Print Hex$(RTCBUFF(I+1));"|";Hex$(RTCBUFF(I+2));"|";
Print Hex$(RTCBUFF(I+3));"|";Hex$(RTCBUFF(I+4));"|";Hex$(RTCBUFF(I +5));"|";
Print Hex$(RTCBUFF(I+6));"|";Hex$(RTCBUFF(I+7));"||";(I+7)
Next I


regards
boss
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024