S12X CW4.5 Linker and variables

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S12X CW4.5 Linker and variables

跳至解决方案
4,668 次查看
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!??
 
 
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,008 次查看
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 项奖励
回复
6 回复数
1,008 次查看
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 项奖励
回复
1,008 次查看
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 项奖励
回复
1,008 次查看
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 项奖励
回复
1,008 次查看
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 项奖励
回复
1,009 次查看
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 项奖励
回复
1,008 次查看
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 项奖励
回复