S12X CW4.5 Linker and variables

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

S12X CW4.5 Linker and variables

Jump to solution
4,674 Views
gravity
Contributor I
I'm am trying to allocate variable in external RAM on the S12x in global addresses i.e 0x100000 or 0x400000
 
I specify these addresses in the  the linker prm file. (There is a note in the linker file indicating addresses should be specified as logical addresses, though)
 
When debugging the address of the variables are missing the top 8 bits, i.e. they appear as 0x0000.
 
So, my question is, how do I specifiy in the linker file, or source file, such that a variable will have an address that is only avaiable via the global address space.
 
And does that question make sense!??
 
 
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,014 Views
CrasyCat
Specialist III

Hello

Just a small correction here.

Make sure to define your variable in a __GPAGE_SEG segment as follows:

#pragma DATA_SEG __GPAGE_SEG MY_INT
int my_int;
#pragma DATA_SEG DEFAULT

CrasyCat

View solution in original post

0 Kudos
Reply
6 Replies
1,014 Views
gravity
Contributor I

Yeah,

Thats what I figured. With the S12 I could do this.

 

nvm.data = 0x23;

and it would be routed through the datapage routines because nvm was mapped to a far (but not physically present) address. Now I'll have to change it to

NVMWrite( nvm.data, 0x23);

 

 

0 Kudos
Reply
1,014 Views
gravity
Contributor I
Hi,
 
Thanks. That exactly the answer I was looking for. I did'nt know how to specify global addresses in the linker file.
 
And additional Question.
 
In the S12 there was a file datapage.c which had several far access runtime routines (LOAD_FAR, STORE_FAR). I used these to intercept far access and redirect them to port driven RAM routines.
 
These datapage routines no longer seem available. I'd rather not go through my code and explicitly use my Port driven RAM I/O routines directly.
 
I could compile as S12 but then I lose all that paged RAM etc.
 
Any ideas?
 
0 Kudos
Reply
1,014 Views
Technoman64
Contributor III
The compiler will use the new Global addressing instructions instead of the code sections to access the global variables. There is very little overhead using global addressing with HCS(X) core.
 
If you are using the standard HCS core then the old datapage routines will be needed.
0 Kudos
Reply
1,014 Views
pittbull
Contributor III
Hi,
Try it this way:

Modify your linker.prm.
In the SEGMENTS section write:
EXTERNAL_INT = READ_WRITE 0x100000'G TO 0x100001'G;
In the PLACEMENT section write:
MY_INT INTO EXTERNAL_INT

To access these locations from C as an integer variably type in your C code:
#pragma DATA_SEG MY_INT
int my_int;
#pragma DATA_SEG DEFAULT

Now you should have an 'int' variable at address 100000'G
Hope that helps.
pittbull
0 Kudos
Reply
1,015 Views
CrasyCat
Specialist III

Hello

Just a small correction here.

Make sure to define your variable in a __GPAGE_SEG segment as follows:

#pragma DATA_SEG __GPAGE_SEG MY_INT
int my_int;
#pragma DATA_SEG DEFAULT

CrasyCat

0 Kudos
Reply
1,014 Views
Sten
Contributor IV
I'm not sure if it answers your question, but take a look at the GlobalAddressing project found among the CW examples (...\(CodeWarrior_Examples)\HCS12X\GlobalAddressing).
 
Sten
 
0 Kudos
Reply