9.2.8 __EEPROM_DATA Macro

A macro that stores values in the device’s EEPROM registers at the time of programming.

Include

<xc.h>

Prototype

__EEPROM_DATA(value, value, value, value, value, value, value, value);

Arguments

value
One of eight values that are to be programmed to EEPROM

Remarks

This macro is used to store initial values in the device’s EEPROM registers at the time of programming.

The macro must be given blocks of 8 bytes to write each time it is called and can be called repeatedly to store multiple blocks.

The macro will begin writing to EEPROM address zero and auto-increment the address by 8 each time it is used.

Example

Several routines which can read EEPROM have been shown in this example, alone with a macro that can store data into the device.
#include <xc.h>
#include <stdio.h>

__EEPROM_DATA(0x00, 0x20, 0x40, 0x60, 0x80, 0x00, 0x00, 0x00);

void main(void) {
  unsigned char byte;

  SYSTEM_Initialize();

  byte = eeprom_read(3);
  printf("Byte at address 3 in EEPROM is %x\n", byte);
  byte = EEPROM_READ(4);
  printf("Byte at address 4 in EEPROM is %x\n", byte);
    
  while (1) {
  }
}
Example Output
Byte at address 3 in EEPROM is 60
Byte at address 4 in EEPROM is 80