9.2.6 EEPROM_READ Macro

A macro that reads data from the EEPROM memory space.

Include

<xc.h>

Prototype

unsigned char EEPROM_READ(scalar address);

Argument

address
The EEPROM address to read

Remarks

This macro is available for all Mid-range devices that implement EEPROM. It is recommended that for PIC18 devices you use MPLAB MCC to generate EEPROM access code, if possible.

Unlike the eeprom_read function, this macro does not wait for any concurrent writes to EEPROM to conclude before performing the required operation. It read the EEPROM and returns the value at the nominated address.

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