Locating variables at fixed addresses (MPC55xx)

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

Locating variables at fixed addresses (MPC55xx)

2,382 Views
james-lee
NXP Employee
NXP Employee
Hello,
 
I have few concerns with CodeWarrior MPC55xx build toolsBuild environment: CW for MPC55xx v2.0.
I want to place the variables a, b, and c in the segment ".APPL_16BIT_RAM" and defined the variables as follow.
 
#pragma push
#pragma section data_type ".APPL_16BIT_RAM" ".APPL_16BIT_RAM"
    unsigned short a;
    unsigned short b;
    unsigned short c;
#pragma pop
 
But the memory segment ".APPL_16BIT_RAM" was empty in the ".map" file which is generated from the source code. By default, the variables 'a', 'b' and 'c' are placed in ".sbss".
 
Of course, I know __declspec(section), but the usage of that for each variable makes the cocde compiler dependent and the memory mapping requirements of AUTOSAR cannot be met with this approach. According to AUTOSAR memory mapping requirements, with the use of single "memmap.h" (which contains #pragma statements), it should be able to place all the CODE and DATA into the required segments. For different compilers, to place the CODE and DATA into required segments, it is enough only to change the "memmap.h" file (no change required in the other source and header files).
 
In the earlier version of CodeWarrior (CodeWarrior Studio V4.5 for MC9S12X), I have developed the code in the following way.
 
#pragma DATA_SEG RAM_8BIT
    unsigned short a;
    unsigned short b;
    unsigned short c;
#pragma DATA_SEG DEFAULT
 
I am expecting something similar to this mechanism.
 
Best regards,
James
 
Labels (1)
0 Kudos
2 Replies

373 Views
CrasyCat
Specialist III
Hello
 
Front end for HCS12X & MPC55xx is s little bit different when it comes to section definition.
So you cannot use the same notation to define a section on MPC55xx and HCS12X.
 
The problem here is that your variable size is smaller than 8 byte, so the compiler internally place them in sbss instead of bss.
 
You have two solutions here.
  1- Define the variable in a sdata section.
      Just change the section definition as follows:
           #pragma push
           #pragma section sdata_type ".APPL_16BIT_RAM" ".APPL_16BIT_RAM"
               unsigned short a;
               unsigned short b;
               unsigned short c;
           #pragma pop
  2- Change the small data threshold setting for the project
      If you are building from the IDE
      - Open your project in the IDE
      - Open the Target Settings dialog (Press ALT + F7)
      - Switch to "+EEPC Target" Panel
      - Set "Small Data" and "Small Data 2" to 0
      - Click OK to close the dialog.
   
     If you are building from batch add following options to your command line:
      -sdatathreshold 0 -sdata2threshold 0
  
    With this settings, the compiler will not use section sbbs, sdata, sdata2 and sbbs2 any more
 
  I hope this helps.
 
CrasyCat
0 Kudos

373 Views
james-lee
NXP Employee
NXP Employee
Hello  CrasyCat,
 
It is very helpful for me. Thank you so much!
 
Best regard,
James
0 Kudos