Memory segmentation problem on DEMO9S12XEP100

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

Memory segmentation problem on DEMO9S12XEP100

447 Views
pabloestebancam
Contributor II

Hi.

Using CodeWarrior 5.1 (cannot use another version), I need to create three memory sections for variables of data type UINT8, UINT16 and UINT32, but I cannot put the variables in the appropriate section.

 

1) In the Linker Parameter File (Project.prm), in the section "SEGMENTS ... END", I have allocated space for 10 variables of each type, in the following way:

 

/* non-paged RAM */

      RAM               = READ_WRITE  DATA_NEAR            0x2000 TO   0x2FFF;

      UINT8_SE      = READ_WRITE  DATA_NEAR            0x3000 TO   0x300A; /* Space for 10 variables UINT8 */

      UINT16_SE     = READ_WRITE  DATA_NEAR            0x300B TO   0x301F; /* Space for 10 variables UINT16 */

      UINT32_SE     = READ_WRITE  DATA_NEAR            0x3020 TO   0x3048; /* Space for 10 variables UINT32 */

 

2) In the "PLACEMEND ... END " section:

 

      DEFAULT_RAM             /* all variables, the default RAM location */

                        INTO  RAM, UINT8_SE, UINT16_SE, UINT32_SE;

    

(...)

 

      DATA_DISTRIBUTE   DISTRIBUTE_INTO

                              RAM, UINT8_SE, UINT16_SE, UINT32_SE,  (...)

 

3) Then, I have created a "pragmas.h" file:

 

#ifndef PRAGMAS_H  

#define PRAGMAS_H

 

#pragma DATA_SEG UINT8_SE

extern UINT8 var1;

#pragma DATA_SEG UINT16_SE

extern UINT16 var2;

#pragma DATA_SEG UINT32_SE

extern UINT32 var3;

#pragma DATA_SEG DEFAULT

 

4) And, in the "main.c" file:

 

#include <hidef.h>           /* common defines and macros */

#include "derivative.h"      /* derivative-specific definitions */

#include "typedefs.h"

#include "pragmas.h"         /* pragmas header file */

 

#pragma DATA_SEG UINT8_SE

UINT8   var1 = 2;

#pragma DATA_SEG UINT16_SE

UINT16  var2 = 3;

#pragma DATA_SEG UINT32_SE

UINT32  var3 = 4;

#pragma DATA_SEG DEFAULT

 

void main(void) { .... }

 

5) BUT, my problem is here: when I compile ("make") the project, and check the "Project.map" file, I can see this:

 

- VARIABLES:

     var1                                      2100       1       1       2   UINT8_SE   

     var2                                      2101       2       2       2   UINT16_SE  

     var3                                      2103       4       4       4   UINT32_SE

 

So, as you can see, the variables var1, var2 and var3 are allocated in 0x2100 .... 2103. They are NOT allocated as expected, from 0x3000 to 0x3048.

 

Could you please tell me what I am doing wrong, or what I am missing?

Thanks in advance!

 

Note: I am following CodeWarrior instructions from: "CW_Compiler_HC12_RM.pdf" (pags. 409ss).

 

/* in a header file */

#pragma DATA_SEG __SHORT_SEG SHORT_MEMORY

extern int i_short;

#pragma DATA_SEG CUSTOM_MEMORY

extern int j_custom;

#pragma DATA_SEG DEFAULT

 

/* in the corresponding C file : */

#pragma DATA_SEG __SHORT_SEG SHORT_MEMORY

int i_short;

#pragma DATA_SEG CUSTOM_MEMORY

int j_custom;

#pragma DATA_SEG DEFAULT

Labels (1)
2 Replies

325 Views
trytohelp
NXP Employee
NXP Employee

Hi Pablo,

The problem is in the prm file.

At point 2 ...

2) In the "PLACEMEND ... END " section:

      DEFAULT_RAM            /* all variables, the default RAM location */

                        INTO  RAM, UINT8_SE, UINT16_SE, UINT32_SE;

This says that all DEFAULT_RAM must be located in RAM, UINT8_SE, UINT16_SE, UINT32_SE memory segment.

This is not what you're looking for.

For my understanding you want to have the following:

    var1    in  UINT8_SE    at 0x3000

    var2    in  UINT16_SE  at 0x300B

    var3    in  UINT32_SE  at 0x3020

To do that you must define in the placement the section name.

You must replace the line

      DEFAULT_RAM            /* all variables, the default RAM location */

                        INTO  RAM, UINT8_SE, UINT16_SE, UINT32_SE;

by

      DEFAULT_RAM            /* all variables, the default RAM location */

                        INTO  RAM;

    UINT8_SE INTO UINT8_SE;

    UINT16_SE INTO UINT16_SE;

    UINT32_SE INTO UINT32_SE;

The pragma must be used as:

#pragma CODE_SEG <segment_name>

#pragma DATA_SEG <segment_name>

Attached you will find an example which could help you to understand how the pragma can be used.

Hope this will help.


Have a great day,
Pascal
Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

325 Views
pabloestebancam
Contributor II

Perfect, Pascal !!

Thanks a lot for your answer!

We have found the solution yesterday and you are confirming it now!

Thanks again.

Pablo.