I'm using MPLABx, XC8 lite and a P18LF14k22
I want to program a value (a preset 'address') into the EEPROM when its programmed. How do I do this under XC8.
Previously under C18 I used the following and it worked fine:
#pragma romdata eedata_scn=0xf00000 // 3 lines instruct compiler to
rom unsigned char eedata_values[1] = {'0'}; // preload address "0" ==> eeprom
#pragma romdata
Below is what I think is the appropriate section from the XC8 Compiler User Manual:
2.5.9 EEPROM Objects
The __eeprom qualifier can be used to indicate that variables should be positioned in
EEPROM.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this qualifier.
Some devices may not implement EEPROM. Use of this qualifier for such devices
generates a warning. Stack-based (auto and parameter) variables cannot use the
__eeprom specifier.
2.5.9.1 EXAMPLE
The following shows a variable qualified using __eeprom.
__eeprom int serialNos[4];
2.5.9.2 DIFFERENCES
The 8-bit compilers have used the qualifier, eeprom, to indicate this meaning for some
devices.
The 16-bit compilers have used the space attribute to allocate variables to the memory
space used for EEPROM.
2.5.9.3 MIGRATION TO THE CCI
For 8-bit compilers, change any occurrence of the eeprom qualifier to __eeprom, e.g.,
from:
eeprom char title[20];
to:
__eeprom char title[20];
For 16-bit compilers, change any occurrence of the eedata space attribute to
__eeprom, e.g., from:
int mainSw __attribute__ ((space(eedata)));
to:
int __eeprom mainSw;
2.5.9.4 CAVEATS
MPLAB XC8 does not implement the __eeprom qualifiers for any PIC18 devices; this
qualifier works as expected for other 8-bit devices.
How do I interpret that?
It seems to be saying that you can't write values to EEPROM directly in the compiler for 8 bit / P18 devices with XC8
I've tried a few variations of the __eeprom / eeprom command but they won't compile.
Google's not been helpful to me today! Anyone know how I should do this please.