PDA

View Full Version : issues with 24lc1025



johnmiller
- 17th June 2007, 09:42
Hi. Can anybody please explain (with source code if possible) how to access memory over 65535 (I can't use the 24lc1025 over 65535) and how can I append data to the memory (if I switch off the power and turn it back on I want to know where to continue from).

Thanks

mister_e
- 17th June 2007, 10:23
<IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1748&stc=1&d=1182071605">

In your code you should be able to modify bit3 of your control byte OR you could use 2 different constant


Block0 CON %10100000
Block1 CON %10101000


and later you just need to use the according constant


I2CREAD SDA,SCL, Block0, Addr,[YourVar] ' read from Block0
I2CREAD SDA,SCL, Block1, Addr,[YourVar] ' read from Block1
<hr>
You could store the address and the Block in the PIC internal EEPROM (if equipped with) when you turn off the PSU. Battery back-up? Nah, i don't think so.
http://www.picbasic.co.uk/forum/showpost.php?p=3452&postcount=3

Or it could be possible to detect a Brown-out/Power Down event.
<hr>
There's still the option to scan The Whole EEPROM until you reach a specific value or detect a blank cell ($FF).

But... How long this will need ? :eek:

johnmiller
- 17th June 2007, 13:39
Thanks, but can you please provide me with some code that actually writes to PIC's EEPROM the location where it should continue from, and the one with addressing over 65536 (since this part I didn't really get it)

skimask
- 17th June 2007, 19:29
Thanks, but can you please provide me with some code that actually writes to PIC's EEPROM the location where it should continue from, and the one with addressing over 65536 (since this part I didn't really get it)

There's a few search hits here that talk specifically about that issue and the fix for it...

mister_e
- 17th June 2007, 21:26
I think something like that have to work

<font color="#000000">Address <font color="#000080">VAR WORD
</font>OldAddress <font color="#000080">VAR WORD
</font>ControlByte <font color="#000080">VAR BYTE
</font>Block0 <font color="#000080">CON </font>%10100000
Block1 <font color="#000080">CON </font>%10101000

Address=0
ControlByte = Block0

Start:
<font color="#000080">I2CWRITE </font>SDA, SCL, ControlByte, Address, [0]
<font color="#000080">PAUSE </font>10
OldAddress = Address
Address = Address + 1
<font color="#000080">IF </font>Address&lt;OldAddress <font color="#000080">THEN </font><font color="#008000">' Overflow?
' ---- YES
</font><font color="#000080">IF </font>ControlByte=Block0 <font color="#000080">THEN </font><font color="#008000">' Are we in Block0?
' ---- YES
</font>ControlByte=Block1 <font color="#008000">' Switch To Block1
</font>Address = 0 <font color="#008000">' Start at first address
</font><font color="#000080">ELSE </font><font color="#008000">' ---- NO
</font><font color="#000080">STOP </font><font color="#008000">' EEPROM is full..
</font><font color="#000080">ENDIF </font><font color="#008000">'
</font><font color="#000080">ENDIF
GOTO </font>Start

Now you just need to keep track of ControlByte and Address values.

HTH

Dave
- 18th June 2007, 21:15
johnmiller, (HINT), Use the page write mode as this will increase the available individual data points you can access. I currently use 2 of them for a total of over 2m bits in my TempTracker fishing accessory to log data at 1 second intervals with 2047 records of 128 bytes in page write mode. They work flawlesly. You might want to use page write mode instead of individual location reads and writes as this speeds up the transfer speed during write mode.
Dave Purola,
N8NTA

johnmiller
- 19th June 2007, 19:46
Thanks mister_e, that worked!

Dave, I tried to write data to the device using page write mode and it works first time, but when I write to it a second time it just overwrites some data. Here is how I write to it:


var SerData byte [80]
I2CWRITE SDApin, SCLpin, ControlByte, i2cAddress, [str SerData\80]
i2cAddress = i2cAddress + 80


any thoughts on this one?

I found the same problem here: http://www.picbasic.co.uk/forum/showthread.php?t=347 but nobody posted any response
Cheers

PS: I think I know why (after reading some on the internet) and now instead of [str SerData\80] I use 128 (since I read that it overwrites that page with the new contents).

Dave
- 20th June 2007, 21:24
johnmiller, Yes it will overwrite the locations because it is only writing 80 bytes instead if 128 bytes before you are changing the address.....
Dave Purola,
N8NTA

novino
- 14th February 2008, 10:44
Hello everyone,
I have the same problem with a 24lc1025, used as a data logger with a 16f876.
It writes and reads fine on the first block, but won't write anything on the second block.
Does anyone have any idea ?

Dave
- 14th February 2008, 12:41
novino, Let's see some code......