Home Digital Load E2PROM with initial values

Load E2PROM with initial values

E-mail Print PDF
( 1 Vote )

Question: I have an E2PROM user module in my project to store some calibration values.  I would like to assign default values to the E2PROM locations when initially programming the device.  Hoe do I do this.

Answer: For example if the E2PROM is placed in the last block of a 32K device and you want to initialize the first 4 bytes with some values.

In C: Use the #pragma abs_address directive and the const keyword to place the initial values in the E2PROM space.

#pragma abs_address 0x7FC0
const char InitialValues[] = {0x00, 0x00, 0xFF, 0xFE};
#pragma end_abs_address

In Assembly: Use the area directive to define a ROM area, set the location using the org directive and place the initial values.

area EepromArea(rom, abs)
org 0x7FC0
db 0x00, 0x00, 0xFF, 0xFE


Comments (0)
Only registered users can write comments!