eeprom_read Function

A function that reads data from the EEPROM memory space.

Include

<xc.h>

Prototype

unsigned char eeprom_read(unsigned char address);

Argument

address
The EEPROM address to read

Remarks

This function is available for all Mid-range devices that implement EEPROM. For PIC18 devices, calls to this routine will instead attempt to call the equivalent functions in the legacy PIC18 peripheral library, which you must download and install separately. It is recommended that for PIC18 devices you use MPLAB MCC to generate EEPROM access code, if possible.

This function tests and waits for any concurrent writes to EEPROM to conclude before performing the required operation.

Example

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

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

  data = eeprom_read(addr);
  printf("The data at EEPROM address %u is %u\n", addr, data); 
}