9.2.4 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>
__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 OutputByte at address 3 in EEPROM is 60
Byte at address 4 in EEPROM is 80