EEPROM Issues

DTN00B

New Member
Hi Everyone and thanks in advance.

I am in the final stages of my RFID Reader based child time management system and i have run into a hitch. EEPROM!!!!

I am using the Picaxe 20M2 for pinout i am using:

C.0 - RFID Reader
C.5, C.3 and C.2 for the two RGB LED's
C.7 For the Relays and the I2C pins for a RTC.

I have custom build the boards that support the hardware and i know that they are all correct.

Now onto my problem. I am trying to take from eeprom a value between 0-255 (although probably nearer 0-120) and add 30 to it and then put it back into eeprom.

For the code i have used poke and peek and for the life of me i cannot get the EEPROM and Read command working.

Code:
Addtime:
	ENum = Tagnum + 80
	peek Enum, b27
	b27=b27+30
	Poke Enum, b27
	debug
	pause 10000
	reset
Please ignore ENum and Tagnum as they work as i have checked through debug and please remember that this code is a small part of my 400 other lines.
 

BeanieBots

Moderator
Peek & Poke are for RAM and do not work with EEPROM

The command EEPROM/DATA is for when you download and sets the initial values. You cannot use them at run-time.

To Read and Write to EEPROM at run-time you must use READ and WRITE.
It really is that simple.

READ Address, Variable
WRITE Address, Variable

There are a few added complications if you want to read/write large amounts of data in one hit but for saving a single byte to a single address is straightforward.
 

DTN00B

New Member
I am aware of this, does the RAM get wiped on a hard reset? also the address values that i have been using are around 80-90.

Also is the write to eeprom command, EEPROM or WRITE ?


Thanks
 

DTN00B

New Member
Looking into the PICAXE manual i have found that EEPROM and Write basically do the same thing, could someone explain the differences please.

Thanks
 

DTN00B

New Member
Your post was perfect but i was told that to write to eeprom the Eeprom command is used. You have mentioned that the write command can be used. I have looked into the picaxe manual and confirmed this but i now dont understand what the difference between the two commands is.

If the write command works when i get to my circuit tomorrow i will be so super happy and i will reply here!

Thanks
 

Technical

Technical Support
Staff member
EEPROM 'preloads' data into EEPROM, only applicable when you do a download to program the PICAXE chip using the download cable.

When the program is running use 'write' instead.
 

BeanieBots

Moderator
In which case you will lose the RAM contents (it gets set to zero).
Anything you WRITE to EEPROM will be preserved.

Also:-
EEPROM data will be lost when you next do a download unless you use the #no_data directive.
 

papaof2

Senior Member
In which case you will lose the RAM contents (it gets set to zero).
Anything you WRITE to EEPROM will be preserved.

Also:-
EEPROM data will be lost when you next do a download unless you use the #no_data directive.
The simplest solution is to add an EEPROM chip to the board and use I2C to talk to it. The external EEPROM will only be written to when you send the command, so no accidental data loss when reprogramming the PICAXE.

Be aware that all EEPROM chips - whether the PICAXE internal EEPROM or an external EEPROM chip - have a limited life (somewhere between 100,000 and 10,000,000 writes, depending on the specific chip - check the datasheet). If your writing will be infrequent, then EEPROM may be OK for your application. If you plan to write once per second or more frequently, then you would be better served by an FRAM chip (ferromagnetic RAM: think magnetic core inside a chip). FRAM is appreciably more expensive than the equivalent memory size in EEPROM, but I think they currently list the life in billions of writes.
 

DTN00B

New Member
The simplest solution is to add an EEPROM chip to the board and use I2C to talk to it. The external EEPROM will only be written to when you send the command, so no accidental data loss when reprogramming the PICAXE.

Be aware that all EEPROM chips - whether the PICAXE internal EEPROM or an external EEPROM chip - have a limited life (somewhere between 100,000 and 10,000,000 writes, depending on the specific chip - check the datasheet). If your writing will be infrequent, then EEPROM may be OK for your application. If you plan to write once per second or more frequently, then you would be better served by an FRAM chip (ferromagnetic RAM: think magnetic core inside a chip). FRAM is appreciably more expensive than the equivalent memory size in EEPROM, but I think they currently list the life in billions of writes.
Thanks, Eeprom is ok for my A-Level project. Im not trying to take over the world. Yet...
 

srnet

Senior Member
If you take the RESET line low, then RAM contents will be preserved.
Sure ?

Manual says;

The reset command is the software equivalent of pressing the external reset switch
(if present). The program is reset to the first line and all variables, stacks etc are
reset.
 

westaust55

Moderator
Note that using the RESET command or the Reset pin on those PICAXE chips with a hardware reset line will also reset ALL variables in RAM to zero.
See:http://www.picaxe.com/BASIC-Commands/Program-Flow-Control/reset/

Also since you have N i2c based RTC chip, note that some include battery backed RAM.
The ubiquitous DS1307 has 56 bytes, the DS3232 has 236 bytes.

Finally, while noting you indicate mist values are up to 120, you do also state in the range 0 to 255, so consider what happens if you have a value greater than 225 and add 30.
Do you need to incorporate the MAX command (hint before adding 30).
 

Paix

Senior Member
Do you need to incorporate the MAX command (hint before adding 30).
A salutatory reminder indeed. Popped into my hints & tips box for future use. I would like to think that it would have been obvious to me, but somehow might have missed a trick. Not now with you having voiced the thought though Westy. Thank you.
 

BeanieBots

Moderator
Sure ?

Manual says;

The reset command is the software equivalent of pressing the external reset switch
(if present). The program is reset to the first line and all variables, stacks etc are
reset.
Well, I thought I was:confused:
I'm convinced that I have an old 28X2 which maintains its scratchpad data after a reset.
 
Top