Using DATA with words?

#1
How do I store word variables in DATA, and get them back again in the same condition? I keep having some kind of "transporter" problem, like in that Star Trek movie...
 

hippy

Technical Support
Staff member
#2
Not entirely sure what you mean by "store word variables in DATA" ...

If you mean include numbers greater than 255 in DATA/EEPROM statements you cannot, you have to split them into two bytes and include each byte value.

If you mean write word variables into the data Eeprom - "WRITE adr, WORD var".

A Programming Editor enahncement to allow "DATA adr,(WORD $1234)" would probably be a welcome addition.
 
#3
Ok thanks, write is working, but it's clunky as hell...I'll have to manually fill as many words as I can spare and fill the EEPROM one chunk at a time, unless there's a better way...as I understand it, the EEPROM erases with a new download, so I can't run a "data entry" program to prefill the values, then load the main program keeping that data intact, right? It doesn't seem to want to let me enter manual numbers with write, only direct byte or word references.
 
#4
It just occurred to me: technically, I could add the data entry segment to the front end of the main program (assuming I had the memory, which I'm sure I won't) and use a persistent variable to only enable it to run the first time the program is booted after download....does the Picaxe have persistent variables?
 
#5
It just occurred to me: technically, I could add the data entry segment to the front end of the main program (assuming I had the memory, which I'm sure I won't) and use a persistent variable to only enable it to run the first time the program is booted after download....does the Picaxe have persistent variables?
No, everything is initilized to zero, I'm pretty sure. External EEPROM devices is how most deal with this requirement. Small 8 pin device can hold 32KB of data, 2 pin I2C interface.

Lefty
 

hippy

Technical Support
Staff member
#6
@ Chris Wells , retrolefty

The DATA/EEPROM is persistent, but not through downloads where data will be initialised to whatever is in DATA/EEPROM statements in the source or reset to zero.

You can create and write data after download and it will still be tehre after every reset, but not after a later download.
 
#7
Of course - I could use the data I entered as a "flag", instead of a normal persistent variable. The beginnning of the program would take a peek at EEPROM, and if the data wasn't zero then the program had been run once already, therefore it would skip the data entry segment. Only an academic exercise, as I won't have the spare memory, but useful to know.
 
Top