5.4.5.2 EEPROM Initialization

For those devices that support external programming of their EEPROM data area, the __EEPROM_DATA() macro can be used to place values into the HEX file ready for programming into the EEPROM. This macro cannot used to write to EEPROM locations during runtime.

The macro is used as follows.

#include <xc.h>
__EEPROM_DATA(0, 1, 2, 3, 4, 5, 6, 7);

The macro has eight parameters, representing eight data values. Each value should be a byte in size. Unused values should be specified with zero.

The __EEPROM_DATA() macro arguments expand into assembly code. Ensure that any operators or tokens in argument expressions are written in assembly code (see 6.1 MPLAB XC8 Assembly Language).

The macro can be called multiple times to define the required amount of EEPROM data. It is recommended that the macro be placed outside any function definition.

The values defined by this macro share the EEPROM space with __eeprom-qualified objects, but cannot be used to initialize such objects. The section used by this macro to hold the data values is different to those used by __eeprom-qualified objects. The link order of these sections can be adjusted, if required (see 4.6.12 Mapped Linker Options).

For convenience, the macro _EEPROMSIZE represents the number of bytes of EEPROM available on the target device.