Location - is an optional constant (0-255) which specifies where to begin storing the data in the EEPROM. If no location is specified, storage continues from where it last left off. If no location was initially specified, storage begins at 0.
Data - are constants (value 0-255) which will be stored in the EEPROM.
Specify values to be loaded to internal data EEPROM at time of program download.
If no EEPROM command is used the values are automatically cleared to the value 0 at program download. To prevent this automatic clearing of the memory upon new download a #no_data directive may be used.
The keywords DATA and EEPROM have identical functions and either can be used. This is not an instruction, but a method of pre-loading the microcontrollers data memory. The command does not affect program length. The EEPROM command only applies once at 'new program download'. When a program is being run the read and write commands are used instead to read and write the EEPROM data memory.
All current PICAXE chips have 256 bytes (address 0-255) of EEPROM memory. Only these older (discontinued) parts had less:
PICAXE-28, 28A 0 to 63 PICAXE-08, 18, 28X, 40X 0 to 127
Shared Memory Space
With some PICAXE parts (listed below) the data memory is shared with program memory. Therefore only unused bytes may be used by the EEPROM command. To establish the length of the program use 'Check Syntax' from the PICAXE menu. This will report the length of program. Available data addresses can then be used as follows:
PICAXE-08 / 18 0 to (127 - number of used bytes) PICAXE-08M 0 to (255 - number of used bytes) PICAXE-14M / 20M 0 to (255 - number of used bytes) PICAXE-18M 0 to (255 - number of used bytes) PICAXE- 08M2 / 18M2 (not 18M2+) Program 1792 up to 2048 is EEPROM 255 to 0
So on 08M2/18M2 all bytes of EEPROM are available for data storage if the program is shorter than 1792 bytes long.
Save data in EEPROM
Store the ascii data "Hello World" in EEPROM locations 0 to 10
Submit Your Own Code!
You must be logged in to submit code examples. Login now.