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

#include <xc.h>
#include <stdio.h>

int main (void)
{
  unsigned char SerNo;
  unsigned char addr = 0x20;

  // wait for end-of-write before EEPROM_READ
  while(WR)
    continue;    // read from EEPROM at address
  serNo = EEPROM_READ(addr);
  printf("The data at EEPROM address %u is %u\n", addr, SerNo); 
}