24.4.9 EEPROM Objects

The __eeprom qualifier can be used to indicate that variables should be positioned in EEPROM.

Use the native keywords discussed in the Differences section to look up information on the semantics of this qualifier.

Some devices may not implement EEPROM. Use of this qualifier for such devices generates a warning. Stack-based (auto and parameter) variables cannot use the __eeprom specifier.

Example

The following shows a variable qualified using __eeprom.

__eeprom int serialNos[4];

Differences

When targeting PIC devices, the MPLAB XC8 compiler has used the eeprom qualifier to indicate that objects should be placed in EEPROM.

The MPLAB XC16 and XC-DSC compilers have used the space attribute to allocate variables to the memory space used for EEPROM.

Migration to the CCI

When using MPLAB XC8 to build for PIC devices, change any occurrence of the eeprom qualifier to __eeprom, for example, from:

eeprom char title[20];

to:

__eeprom char title[20];

When using MPLAB XC16 or XC-DSC compilers, change any occurrence of the eedata space attribute to the __eeprom specifier, for example, from:

int mainSw __attribute__ ((space(eedata)));

to:

int __eeprom mainSw;

Caveats

The MPLAB XC8 compiler only permits the __eeprom specifier for those Baseline and Mid-range devices that support this memory. It is not permitted for other 8-bit devices.