Another segments thread, segment is not at correct address

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Another segments thread, segment is not at correct address

Jump to solution
2,622 Views
CarlFST60L_3rd
Contributor I
Hi,

Sorry to start another thread on this topic.

I had this problem the a couple of weeks ago and worked it out, but had no luck today..

I created a new project using MC9RS08KA2, just C code.

I am making a const_seg (MYROMTABLE), but the data just isnt at the specified address (0x3800), here is a copy and past of the code i have added to the project.

main.c
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

//Added this
#pragma CONST_SEG MYROMTABLE
const byte test = 0x0F;
const byte test2 = 0xF0;
const byte test3 = 0xFF;
#pragma CONST_SEG DEFAULT


void main(void) {

  EnableInterrupts; /* enable interrupts */
  /* include your code here */

  for(;:smileywink: {
    __RESET_WATCHDOG(); /* feeds the dog */
 //added this
  PTADD = test;
 
  } /* loop forever */
  /* please make sure that you never leave main */
}

PRM file

/* This is a linker parameter file for the MC9RS08KA2 */

NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
    RESERVED_RAM             =  NO_INIT      0x0000 TO 0x0004;
    TINY_RAM                 =  READ_WRITE   0x0005 TO 0x000D;
    DIRECT_RAM               =  READ_WRITE   0x0020 TO 0x004F;
    FLASHROMTABLE            =  READ_ONLY    0x3800 TO 0x38FF;
    ROM                      =  READ_ONLY    0x3900 TO 0x3FF7;
//  RESET_JMP_AREA           =  READ_ONLY    0x3FFD TO 0x3FFF; // area defined by RESET 0 below.
END

PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
    RESERVED                 INTO RESERVED_RAM;
    TINY_RAM_VARS            INTO TINY_RAM;
    DIRECT_RAM_VARS,
    DEFAULT_RAM              INTO DIRECT_RAM, TINY_RAM;
    MYROMTABLE               INTO FLASHROMTABLE;
    DEFAULT_ROM              INTO ROM;
END


STACKSIZE 0x00 /* no stack for RS08 */

VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */




Labels (1)
Tags (1)
0 Kudos
1 Solution
439 Views
CompilerGuru
NXP Employee
NXP Employee
Check your map file, my guess is that this test (and test2, test3) constants are not used at all.

The compiler is using the 0x0F number instead of the test constant, I think if you do not want this to happen, making test volatile is the right thing to do as there is more to the test constant than its 15 value.

See also

http://forums.freescale.com/freescale/board/message?board.id=CW816COMM&message.id=2704

http://forums.freescale.com/freescale/board/message?board.id=CW816COMM&message.id=3060&query.id=2421...


this topic has been discussed a few times before, also search the forum.

Daniel

View solution in original post

0 Kudos
3 Replies
440 Views
CompilerGuru
NXP Employee
NXP Employee
Check your map file, my guess is that this test (and test2, test3) constants are not used at all.

The compiler is using the 0x0F number instead of the test constant, I think if you do not want this to happen, making test volatile is the right thing to do as there is more to the test constant than its 15 value.

See also

http://forums.freescale.com/freescale/board/message?board.id=CW816COMM&message.id=2704

http://forums.freescale.com/freescale/board/message?board.id=CW816COMM&message.id=3060&query.id=2421...


this topic has been discussed a few times before, also search the forum.

Daniel
0 Kudos
439 Views
CarlFST60L_3rd
Contributor I
Thanks, problem has been solved

ftr, i have two projects, one created for RS08KA2 and one for S08GT32, both require diffrent approachs to solve this problem..

RS08 required:
const byte __far StatusByte1 = 0x87;    //Added __far as it caused the fixup error
&
"-OnCstVar" option

GT32 required neither, it just works as expected, no __far no "-OnCstVar" option, and it works 100%. I am only using a struct and pointers to that stuct on the GT32, maybe that is the diffrence, maybe its the memory setup on the RS08..






0 Kudos
439 Views
CompilerGuru
NXP Employee
NXP Employee
Instead of the explicit far for every variable, the section should be qualified with

#pragma CONST_SEG __PAGED_SEG MYROMTABLE

if the section does not cross a 64 byte boundary or

#pragma CONST_SEG __FAR_SEG MYROMTABLE

otherwise. Using far instead of __paged can cause considerably more code to be generated, but not for single byte variables/constants though.

Daniel
0 Kudos