I'm using SDCC v3.2.0.
The USB module in the PIC18F14K50 requires that all USB related data be put in RAM at addresses between 0x200 and 0x2FF. I've written a light-weight USB stack before, but I ended up using SDCC's absolute addressing syntax of:
Obviously, specifying the address of every variable related to USB is pretty clunky. Instead, I would like to tell the compiler which databank to put those variables in and let the linker do its job.
In the SDCC manual, on page 73, it shows an example of doing this. However, I haven't gotten it to successfully work. Here's my modified linker script. All I changed was adding the "SECTION" line at the bottom.
And here's my basic program using the pragma syntax from the SDCC manual.
It appears the #pragma isn't doing anything. Based on the printed value of (int)pa, the location of "a" appears to be in gpr0 with or without the #pragma. Incidentally, if I specify the absolute address using the __at command, then printing (int)pa gives me the correct value. So I know my pointers and print statement are working. Any ideas what I'm doing wrong?
The USB module in the PIC18F14K50 requires that all USB related data be put in RAM at addresses between 0x200 and 0x2FF. I've written a light-weight USB stack before, but I ended up using SDCC's absolute addressing syntax of:
Code:
varType __at (0x200) varName; //Puts variable varName at RAM address 0x200
In the SDCC manual, on page 73, it shows an example of doing this. However, I haven't gotten it to successfully work. Here's my modified linker script. All I changed was adding the "SECTION" line at the bottom.
Code:
LIBPATH .
CODEPAGE NAME=page START=0x0 END=0x3FFF
CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED
CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED
ACCESSBANK NAME=accessram START=0x0 END=0x5F
DATABANK NAME=gpr0 START=0x60 END=0xFF
DATABANK NAME=gpr1 START=0x100 END=0x1FF
DATABANK NAME=gpr2 START=0x200 END=0x2FF
DATABANK NAME=sfr15 START=0xF40 END=0xF5F PROTECTED
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED
SECTION NAME=bank2 RAM=gpr2 #I added this line
Code:
void main()
{
#pragma udata bank2 a
unsigned char a;
unsigned char* pa = &a;
print16bitVal((int)pa);
while(1);
}