English
Language : 

PIC24F16KL402 Datasheet, PDF (58/260 Pages) Microchip Technology – Low-Power, Low-Cost, General Purpose 16-Bit Flash Microcontrollers with nanoWatt XLP Technology
PIC24F16KL402 FAMILY
6.4.3 READING THE DATA EEPROM
To read a word from data EEPROM, the table read
instruction is used. Since the EEPROM array is only
16 bits wide, only the TBLRDL instruction is needed.
The read operation is performed by loading TBLPAG
and WREG with the address of the EEPROM location
followed by a TBLRDL instruction.
A typical read sequence, using the Table
Pointer management (builtin_tblpage and
builtin_tbloffset) and table read
(builtin_tblrdl) procedures from the C30
compiler library, is provided in Example 6-5.
Program Space Visibility (PSV) can also be used to
read locations in the data EEPROM.
EXAMPLE 6-5: READING THE DATA EEPROM USING THE TBLRD COMMAND
int __attribute__ ((space(eedata))) eeData = 0x1234;
int data;
unsigned int offset;
// Global variable located in EEPROM
// Data read from EEPROM
// Set up a pointer to the EEPROM location to be erased
TBLPAG = __builtin_tblpage(&eeData);
// Initialize EE Data page pointer
offset = __builtin_tbloffset(&eeData);
// Initizlize lower word of address
data = __builtin_tblrdl(offset);
// Write EEPROM data to write latch
DS31037B-page 58
 2011 Microchip Technology Inc.