Simple question on how to use Propeller EEPROM object
Need some help here determining what Im doing wrong. Im trying to learn how to save data to EEPROM so I can retrieve it back. Below is the code. It should be pretty straight forward.
Thank You
Steve Woodrough
Thank You
Steve Woodrough
{{
Experiment to understand how to read and write data to the EEPROM. Will be used in my Magellan Bot project.
}}
CON ' Constant declarations
' System clock settings - 80 MHz
_clkmode = xtal1 + pll16x ' Low speed external crystal 16x PLL
_xinfreq = 5_000_000 ' Crystal input frequency is 5 MHz
VAR ' Variable declarations
long A,B,C,D
OBJ ' Object declarations
eeprom : "Propeller Eeprom" ' Propeller EEPROM object
FDS : "FullDuplexSerialPlus" ' PST
Pub Main
FDS.start(31, 30, 0, 115200)
waitcnt(clkfreq+cnt) 'Pause a second
fds.getstr(string(" ")) 'Wait for enter key
repeat
fds.str(string(13,"Retrieving data from EEPROM"))
eeprom.FromRam(@A,@D, 0) 'Should be retrieving whatever is in EEPROM
fds.str(string(13,"Data retrieved from EEPROM"))
fds.str(string(13,"Value of A from EEPROM = "))
fds.dec(A)
fds.str(string(13,"Value of B from EEPROM = "))
fds.dec(B)
fds.str(string(13,"Value of C from EEPROM = "))
fds.dec(C)
fds.str(string(13,"Enter A",13))
A:=fds.getdec
fds.str(string("Enter B",13))
B:=fds.getdec
fds.str(string("Product is = "))
C:=A*B
fds.dec(C)
fds.str(string(13,"Saving data to EEPROM"))
eeprom.FromRam(@A,@D, 0) 'Should be writng variable data to EEPROM
fds.str(string(13,"Data saved to EEPROM"))
A:=B:=C:=D:=0 'Zero out values

Comments
To save your variable "A" to EEPROM in the same location in the EEPROM use:
You need to add the "+ 3" to include the three additional bytes in the long besides the byte located at @A.
To read this data back from EEPROM use:
If you want to use free sections of the EEPROM that won't be overwritten when you save a new program, use addresses higher than $8000 (assuming your have a 64K EEPROM).
So to write your variable "A" to upper EEPROM, use:
To write all four variables to upper EEPROM, use:
or
Thank you for taking the time.
Point taken on the choice of address. I'll move it up the range. I was just trying to get a result to get a feel for the object.
Regards,
Steve
Don't use the program as a guide to using EEPROM. It's full of bugs. The part which checks the size of the EEPROM works but not much else.