How do I reset EEPROM data on PICAXE 20X2?

geditor

New Member
In BASIC, i have set some EEPROM memory:
EEPROM 30, ("Hello")

It goes to the LCD display via a function but then I need to know how do I clear the EEPROM (from 30 - preferable if there is a way) so that I can write to the same location again?
Thanks in advance
________
Ship Sale
 
Last edited:

BeanieBots

Moderator
Welcome to the forum!

Not totally clear on exactly what you want to do.

The EEPROM command writes to EEPROM during download.
To change the EEPROM during runtime, use the command WRITE.
 
Last edited:

Chavaquiah

Senior Member
You don't have to clear EEPROM before writing to it again. If you really, really want to, you can use the WRITE command. For instance:

write 30, 0, 0, 0, 0, 0

However, this should be avoided. EEPROMs do wear out with each write (although they're good for several thousand writes).

I should note, however, that the EEPROM instruction only initializes EEPROM during download. If your program rewrites the locations initialized with the EEPROM instruction, those changes are permanent. Next time your program restarts, the initial string won't be there. You could, of course, write it back with (again) the WRITE command.
 

geditor

New Member
Thanks very much Chavaquiah.
However you mention that I can write to the EEPROM without clearing it, If a run one EEPROM function followed by another one storing in the same location, PICAXE Programming Editor says EEPROM storage is already in use so I do know if it will still work when I program it into the PICAXE. Any advice on this also?
Sorry, I am really new to programming with PICAXE's and have just started my first year in it.
________
Subaru Ff-1 Star Specifications
 
Last edited:

BeanieBots

Moderator
No need to clear the EEPROM before assigning a different value.
You can only assign a location using the command EEPROM ONCE.

As I said earlier, if you want to change the value during runtime you need to use WRITE. You cannot have multiple EEPROM statements for the same location in the same program.

EEPROM (or DATA) sets the value at download time.
WRITE changes the value under program control.
 

Chavaquiah

Senior Member
Wow! I didn't know the PE did this check for EEPROM data. That's actually very useful. :)

BeanieBots explained very clearly the difference between DATA (or EEPROM) and WRITE. Since the former presets the memory even before the program starts running, it would not make sense to try and write two different things to the same address. Doing so would probably be an involuntary error and it's a good thing the Programming Editor warns about it.

DATA should be used only for constants (that never change). Everything else should be written (and rewritten) at runtime, with WRITE. I suspect all you have to do is replace the EEPROM command with WRITE, to solve the error.

As for being new to Picaxe's programming, don't worry - you'll find this system is very user friendly and becomes very easy in no time. Besides, you can always use this forum to ask for help, advice or suggestions. One can always learn even from simple questions.
 

westaust55

Moderator
Thanks very much Chavaquiah.
However you mention that I can write to the EEPROM without clearing it, If a run one EEPROM function followed by another one storing in the same location, PICAXE Programming Editor says EEPROM storage is already in use so I do know if it will still work when I program it into the PICAXE. Any advice on this also?
Sorry, I am really new to programming with PICAXE's and have just started my first year in it.
This sounds/reads more as if you have two EEPROM directives in the program trying to use the same locations.

If I do:

Code:
EEPROM 30, ("Hello")  ; this occupies EEPROM data locations, 30, 31, 32, 33,34
EEPROM 32, ("WA-55") ; this tries to occupy EEPROM data locations, 32, 33, 34, 35,36
then becasue of the overlap, for the second line I get
Error: EEPROM location already used!​


Note that with an EEPROM (or Write) command each character or number occupies the next consecutive space, not all of "Hello" is stores at the one lociation
 
Top