I'm currently having a bad time trying to use an external RAM chip (512 kB) with a PIC18F8720 and the Microchip XC8 compiler (v1.35, PRO mode).
Whenever I try to write some code to modify a variable in the external memory, the linker throws an error (712): "can't generate code for this expression". This doesn't happen when reading far variables: only when writing into them.
This error is reproducible, even in this small example program:
#include <xc.h>
#include <stdio.h>
far int intArray[10];
far int intVariable;
void main(void) {
intVariable = 2; // --> ERROR 712
intArray[1] = 3; // --> ERROR 712
printf("%d\n", intVariable);
printf("%d\n", intArray[0]);
}
The compilation+linking commands are generated by MPLAB X v3.20:
"/opt/microchip/xc8/v1.35/bin/xc8" --pass1 --chip=18F8720 -Q -G --double=24 --float=24 --emi=byteselect --ram=default,+20000-9FFFF --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=require --mode=pro -P -N255 --warn=-3 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/main.p1 main.c
"/opt/microchip/xc8/v1.35/bin/xc8" --chip=18F8720 -G -mdist/default/production/Test01.X.production.map --double=24 --float=24 --emi=byteselect --ram=default,+20000-9FFFF --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=require --mode=pro -P -N255 --warn=-3 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" --memorysummary dist/default/production/memoryfile.xml -odist/default/production/Test01.X.production.elf build/default/production/main.p1
Compilation output:
main.c:9: error: (712) can't generate code for this expression
main.c:10: error: (712) can't generate code for this expression
Microchip MPLAB XC8 C Compiler (PRO Mode) V1.35
Build date: Jul 7 2015
Part Support Version: 1.35
Copyright (C) 2015 Microchip Technology Inc.
License type: Node Configuration
What am I doing wrong? The compiler output doesn't help much, as the error is way too generic to give any clue.