S12X CW4.5 Linker and variables

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S12X CW4.5 Linker and variables

ソリューションへジャンプ
4,441件の閲覧回数
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 解決策
781件の閲覧回数
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 返答(返信)
781件の閲覧回数
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 件の賞賛
返信
781件の閲覧回数
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 件の賞賛
返信
781件の閲覧回数
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 件の賞賛
返信
781件の閲覧回数
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 件の賞賛
返信
782件の閲覧回数
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 件の賞賛
返信
781件の閲覧回数
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 件の賞賛
返信