How do i do so the PIC don't write to same address every time? So each time the PIC write to eeprom it write to a new address.
How do i do so the PIC don't write to same address every time? So each time the PIC write to eeprom it write to a new address.
PBP has a way of looking at the EEPROM addresses as simple numbers.
So you can
WRITE 0
WRITE 1
WRITE 2
all are different places in the EEPROM.
Want to automatically increment?
X = X + 1
WRITE X
Dave
Always wear safety glasses while programming.
I think you may be asking how you write to a different address - even across power cycles.
If that is the case, write to the EEPROM, and then write the last-used address + 1 to the two highest EEPROM addresses (1022 and 1023 on many devices)
Before you write to EEPROM, read those two addresses to get the next address to write to, and when you are done, write the last address + 1 to 1022 and 1023 again.
Charles Linquist
I don't know what I didn't already explain.
But..
When you program your device, make certain that you erase the EEPROM to all '0's'.
Now if you want to write to the EEPROM
READ 1023,WriteStart.LowByte
READ 1024,WriteStart.HighByte
Now write your data -
WRITE WriteStart,(your data goes here)
WriteStart = WriteStart + 1
Now write back the value of WriteStart so it can be the starting address
the next time you WRITE. Every time you issue a WRITE, you need to
increment WriteStart. When you are done writing (or even after every WRITE
if you really want to protect against power failure).
WRITE 1023,WriteStart.LowByte
WRITE 1024,WriteStart.HighByte
Charles Linquist
Just don't make the mistake I just did. The highest address on a 1024 byte EEPROM is 1023!
Charles Linquist
Bookmarks