Peter Richter

incorrect variable pointer for XGATE thread

Discussion created by Peter Richter on Aug 5, 2008
Latest reply on Aug 6, 2008 by Peter Richter
Hello Forum,

I' ve a problem with flw. subject.
I'm using CW 5.7 and a MC9S12XDP512 controller, all code is in assembler. I want to use also the XGATE for some interrupts, but in the moment I've flw. problem.
I placed the XGATE vector block and code in Flash and copied down to RAM during runtime. According to the user manual of the µctrl. it is possible for an XGATE vector to have an additional pointer to the service routine's variable space. This value is loaded into register R1 of XGATE before the thread is executed.
Now flw. problem. I'm using 12kByte RAM, both cores(HC12 and XGATE) shall use it . If the variable is located in RAM space between local address 2000h to 3FFFh (global 0FE000h to 0FFFFh) all works fine, register R1 is loaded correctly. If the variable is located between local address 1000h and 1FFFh (global 0FD000h to 0FDFFFh) I got an incorrect pointer, because only the lower byte is loaded correctly to register R1.
I think it have to be a linker or setting problem of my assembler. But in the moment no idea anymore where to look. Any help highly appreciated.
Attached used linker file.
Code:
/* Register space  */
/*    IO_SEG        = PAGED         0x0000 TO   0x07FF; intentionally not defined */

/* non-paged EEPROM */
      EEPROM        = READ_ONLY     0x0C00 TO   0x0FFF;

/* non-paged RAM */
      RAM           = READ_WRITE    0x1000 TO   0x3F9A  ALIGN 2[1:1]; /* word alignment for XGATE accesses */
      MY_STK        = READ_WRITE    0x3F9B TO   0x3FFF; /* 100byte stack */

/* non-banked FLASH */
      ROM_4000      = READ_ONLY     0x4000 TO   0x7FFF;

      ROM_C000      = READ_ONLY     0xC000 TO   0xF6FF;
       ISR           = READ_ONLY     0xF700 TO   0xF7FF;
      Boot          = READ_ONLY     0xF800 TO   0xFF0F;
       Vector        = READ_ONLY     0xFF10 TO   0xFFFF; /* intentionally not defined: used for VECTOR commands below */

/* paged EEPROM                     0x0800 TO   0x0BFF; addressed through EPAGE */
      EEPROM_FC     = READ_ONLY   0xFC0800 TO 0xFC0BFF;
      EEPROM_FD     = READ_ONLY   0xFD0800 TO 0xFD0BFF;
      EEPROM_FE     = READ_ONLY   0xFE0800 TO 0xFE0BFF;
/*    EEPROM_FF     = READ_ONLY   0xFF0800 TO 0xFF0BFF; intentionally not defined: equivalent to EEPROM */

/* paged RAM:                       0x1000 TO   0x1FFF; addressed through RPAGE */
      RAM_XGATE_STK = READ_WRITE  0xF81000 TO 0xF810FF; /* The stack is set by the XGATE compiler option -Cstv=8100 */
      RAM_F8        = READ_WRITE  0xF81100 TO 0xF81FFF ALIGN 2[1:1]; /* is also mapped to XGATE:  0x8100..0x8FFF */
      RAM_F9        = READ_WRITE  0xF91000 TO 0xF91FFF;
      RAM_FA        = READ_WRITE  0xFA1000 TO 0xFA1FFF;
      RAM_FB        = READ_WRITE  0xFB1000 TO 0xFB1FFF;
      RAM_FC        = READ_WRITE  0xFC1000 TO 0xFC1FFF;
      RAM_FD        = READ_WRITE  0xFD1000 TO 0xFD1FFF ALIGN 2[1:1]; /* is also mapped to XGATE:  0xD000..0xDFFF */
/*    RAM_FE        = READ_WRITE  0xFE1000 TO 0xFE1FFF; intentionally not defined: equivalent to RAM: 0x2000..0x2FFF */
/*    RAM_FF        = READ_WRITE  0xFF1000 TO 0xFF1FFF; intentionally not defined: equivalent to RAM: 0x3000..0x3FFF */

/* paged FLASH:                     0x8000 TO   0xBFFF; addressed through PPAGE */
      PAGE_E0       = READ_ONLY   0xE08000 TO 0xE0BFFF;
      PAGE_E1       = READ_ONLY   0xE18000 TO 0xE1BFFF;
....
       PAGE_FA       = READ_ONLY   0xFA8000 TO 0xFABFFF;
      PAGE_FB       = READ_ONLY   0xFB8000 TO 0xFBBFFF;
      PAGE_FC       = READ_ONLY   0xFC8000 TO 0xFCBFFF;
/*    PAGE_FD       = READ_ONLY   0xFD8000 TO 0xFDBFFF; intentionally not defined: equivalent to ROM_4000 */
      PAGE_FE       = READ_ONLY   0xFE8000 TO 0xFEAFFF;
      ROM_XGATE     = READ_ONLY   0xFEB100 TO 0xFEBFFF RELOCATE_TO 0xF81A00 ALIGN 2;
/*    PAGE_FF       = READ_ONLY   0xFF8000 TO 0xFFBFFF; intentionally not defined: equivalent to ROM_C000 */

END

PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */
    
       //_PRESTART,              /* Used in HIWARE format: jump to _Startup at the code start */
      STARTUP,                /* startup data structures */
      ROM_VAR,                /* constant variables */
      STRINGS,                /* string literals */
      VIRTUAL_TABLE_SEGMENT,  /* C++ virtual table segment */
    //.ostext,                /* eventually OSEK code  */
      NON_BANKED,             /* runtime routines which must not be banked */
      CodeFDSect,
      COPY                    /* copy down information: how to initialize variables */
                              /* in case you want to use ROM_4000 here as well, make sure
                                 that all files (incl. library files) are compiled with the
                                 option: -OnB=b */
                        INTO  ROM_4000 /*, ROM_4000*/;

      CodeFESect        INTO  PAGE_FE;
      DEFAULT_ROM       INTO  PAGE_FC, PAGE_FB, PAGE_FA, PAGE_F9, PAGE_F8,  
                               PAGE_F7, PAGE_F6, PAGE_F5, PAGE_F4, PAGE_F3, PAGE_F1, PAGE_F0,  
                               PAGE_EF, PAGE_EE, PAGE_ED, PAGE_EC, PAGE_EB, PAGE_EA, PAGE_E9, PAGE_E8,
                              PAGE_E7, PAGE_E6, PAGE_E5, PAGE_E4, PAGE_E3, PAGE_E2, PAGE_E1, PAGE_E0;

      ConstSect         INTO  ROM_C000;
      EEPromSect        INTO  EEPROM;
      PageF2Sect        INTO  PAGE_F2;
      PageF6Sect        INTO  PAGE_F6;
    
       XGATE_VECTORS,          /* XGATE vector table has to be copied into RAM by HCS12X */
      XGATE_STRING,           /* XGATE string literals have to be copied into RAM by HCS12X */
      XGATE_CONST,            /* XGATE constants have to be copied into RAM by HCS12X */
      XGATE_CODE,             /* XGATE functions have to be copied into RAM by HCS12X */
      XGATE_STRING_RAM,       /* XGATE strings that should always go into RAM */
      XGATE_CONST_RAM,        /* XGATE constants what should always go into RAM */
      XGATE_CODE_RAM          /* XGATE code that should always run out of RAM */
                        INTO  ROM_XGATE; /* will be copied into RAM_F8 */

      SSTACK,           INTO  MY_STK;      /* allocate stack first to avoid overwriting variables */
 
       RAMSect,
      DEFAULT_RAM       INTO  RAM;        /* all variables, the default RAM location */

      PAGED_RAM         INTO  /* when using banked addressing for variable data, make sure to specify
                                  the option -D__FAR_DATA on the compiler command line */
                              /*RAM_F8,*/ RAM_F9, RAM_FA, RAM_FB, RAM_FC /*RAM_FD*/;

      XGATE_DATA,
      PagedRAMSect      INTO  RAM_F8;

      ISR_Sect          INTO  ISR;  /* allocate the ISR into defined ROM area */

      VectorTable       INTO  Vector; /* allocate the vector table into defined ROM area, IVBR: default reset value */

      _PRESTART,              /* jump to _Startup at the code start, place into protected boot section */
      BootSect          INTO  Boot;

END

ENTRIES /* keep the following unreferenced variables */
*
END

//VECTOR 0 main  /* reset vector: this is the default entry point for an Assembly application. */
INIT main      /* for assembly applications: that this is as well the initialization entry point */

 

Outcomes