I am working on a project using a Atmega644 and want to include EEPROM data in the initial programming. I am using MPLAB X and the XC8 compiler (version 2.31) and for programming I am using a PICkit4.
I know that the xc8 compiler for PIC MCUs has the __EEPROM_DATA() macro, that would be pretty much perfect for my usecase. The AVR version of the compiler, however does not appear to have this macro (I tried both with and without CCI syntax...), as it does not recognize the call and just throws an error when trying to compile.
I have looked through the manual for the compiler, but it does not list any macros/functions to do this.
I tried adding the macro myself, by copying it from the PIC compiler to a header in my project, but it seems to contain assembly instructions that do not exist on the atmega and I couldn't even find those in documentation for the PIC (Otherwise I would have tried to find an equivalent instruction and replace them)...
Is there another way to include the initial EEPROM data in the project, so it gets written to the mcu during programming?
__EEPROM_DATA()
macro is supported only for 8-bit PIC baseline and mid-range devices. There is also__eeprom
qualifier to position variables in EEPROM. But none of these are for AVR chips.Microchip supports AVR chips in XC8 using avr headers. There is an eeprom header which has some macros defined. One of these macros is
EEMEM
. You can use it to set EEPROM values at programming time. Here is how you use it:There is good information regarding the usage of this macro in this and this SO answers. Make sure to have a look at them.
I also recommend you to take a look at MPLAB XC8 C Compiler User's Guide for AVR MCU in case you didn't know about it.