PIC24FV16KM204 FAMILY
DS33030A-page 78
Advance Information
2013 Microchip Technology Inc.
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
.
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;
// Data read from EEPROM
/*--------------------------------------------------------------------------------------------
The variable eeData must be a Global variable declared outside of any method
the code following this comment can be written inside the method that will execute the read
----------------------------------------------------------------------------------------------
*/
unsigned int offset;
// 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
Summary of Contents for PIC24FV16KM204 FAMILY
Page 312: ...PIC24FV16KM204 FAMILY DS33030A page 312 Advance Information 2013 Microchip Technology Inc ...
Page 313: ... 2013 Microchip Technology Inc Advance Information DS33030A page 313 PIC24FV16KM204 FAMILY ...
Page 315: ... 2013 Microchip Technology Inc Advance Information DS33030A page 315 PIC24FV16KM204 FAMILY ...
Page 316: ...PIC24FV16KM204 FAMILY DS33030A page 316 Advance Information 2013 Microchip Technology Inc ...
Page 317: ... 2013 Microchip Technology Inc Advance Information DS33030A page 317 PIC24FV16KM204 FAMILY ...
Page 322: ...PIC24FV16KM204 FAMILY DS33030A page 322 Advance Information 2013 Microchip Technology Inc ...