EEPROM constants

Language reference ›› Constants ››
Parent Previous Next

See also: The $SPACE directive, Variables in EEPROM.


NEW! (V2.0): A great PMP feature is its special ability to allow allocation of constants either as literal values or in EEPROM.


- They are great for parameters that may be altered by the programmer without reloading the whole chip.

- They should be used with care since they are more time consuming than literal constants.

- They behave like EEPROM variables with an initial value, but they are read only.

- Constant arrays and strings are allowed.


The $SPACE EEPROM directive may be used to define a bunch of variables, but the EEPROM qualifier may be used to override the current $SPACE RAM to define explicitly one or several variables to be in EEPROM:




CONST
 {$SPACE EEPROM} // next in EEPROM
 EE_BYTE_1: BYTE = $AA; { An EE byte with an initial value }
 EE_STRING_1: STRING[8] = 'Hello!'; { An EE string using 9 bytes, filled by the given string literal }
 {$SPACE RAM} // next in RAM
 MyString: STRING; { string in RAM with a default max length }
 EE_LONGINT_1: EEPROM LONGINT = 12345678; { An EE 32-bit longint with an initial value; the EEPROM keyword overrides the $SPACE RAM }
 EE_STRING_2: EEPROM STRING = 'Hello World!'; { An EE string with a default max length, filled by the given string literal }