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