storage variable in the specific location in memory

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

storage variable in the specific location in memory

4,581件の閲覧回数
VeronicaFNX
Contributor I

Hello,
how I can storage variable in the specific location in memory?
For example I have

char variable;      //I want have variable on address 0x2000 1500

but how it say to compiler?
I'm using Code warrior 6.3 and m52233demo
please help.
Regards
               Vero

ラベル(1)
タグ(1)
0 件の賞賛
返信
8 返答(返信)

2,262件の閲覧回数
CrasyCat
Specialist III
Hello
 
The only way you can get that working is defining a variable in a user specific section and placing the section appropriately in the linker control file.
 
Look at section "Defining Sections in Source Code" in the ColdFire_Build_Tools_Reference.pdf manual for more details.
 
CrasyCat
0 件の賞賛
返信

2,262件の閲覧回数
VeronicaFNX
Contributor I
I have watched the pdf and I do not understand it very well. You can write an example? Thanks
0 件の賞賛
返信

2,262件の閲覧回数
CrasyCat
Specialist III
Hello
In your ANSI C source file define the variable as follows:
 
Code:
#pragma push /* Save the compiler’s state. */#pragma define_section myData ".myData" far_absolute RW#pragma pop__declspec(myData) int variable;

 In the Linker Control File, add a new memory area in the MEMORY block and place the section there (in example below variable will be placed at 0x20007FF0).
Code:
MEMORY { vector_ram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000500 user       (RWX) : ORIGIN = 0x20000500, LENGTH = 0x00007AF0 varSec      (RWX) : ORIGIN = 0x20007FF0, LENGTH = 0x00000010 ipsbar     (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0}SECTIONS { .ipsbar  : {} > ipsbar .vectors : {  . = ALIGN (0x4); } > vector_ram .text : {  *(.text)  .= ALIGN(0x10);  *(.rodata)    .= ALIGN(0x10); } > user  .myData : {  *(.myData) } > varSec .data :  {          <..continue here ..>

That should be it
 
CrasyCat
0 件の賞賛
返信

2,262件の閲覧回数
VeronicaFNX
Contributor I
well…thanks and now I need storage a function in the specific location in memory?
For example I have

int main(void);      //I want have function on address 0x2000 1500

but how it say to compiler? can you write an example? Thanks
I'm using Code warrior 6.3 and m52233demo
regards
               Vero

0 件の賞賛
返信

2,262件の閲覧回数
CrasyCat
Specialist III
Hello
In the source file define the section / function as follows:
 
Code:
#pragma push /* Save the compiler’s state. */#pragma define_section myCode ".myCode" far_absolute RX#pragma pop
__declspec(myCode) void foo(void)
{
 /* Insert Code here */
}

Then place the section .myCode accordingly in the linker command file (something similar to what you did with the variable.
Define a MEMORY area and place the section in there.
CrasyCat
0 件の賞賛
返信

2,262件の閲覧回数
VeronicaFNX
Contributor I
I have watched the pdf and I do not understand it very well. You can write an example? Thanks
 
Your response:
 
Hello
The only way you can get that working is defining a variable in a user specific section and placing the section appropriately in the linker control file.
Look at section "Defining Sections in Source Code" in the ColdFire_Build_Tools_Reference.pdf manual for more details.
 
CrasyCat
 
My request:

how I can storage variable in the specific location in memory?
For example I have
char variable;      //I want have variable on address 0x2000 1500

but how it say to compiler?
I'm using Code warrior 6.3 and m52233demo
please help.

0 件の賞賛
返信

2,262件の閲覧回数
Lundin
Senior Contributor IV
In the prm file:

SECTION
SOME_SECTION_NAME = READ_WRITE 0x0001 TO 0x0001;
END

PLACEMENT
SOME_SEGMENT_NAME INTO SOME_SECTION_NAME;
END


In the c file:

#pragma DATA_SEG SOME_SEGMENT_NAME
char variable;
#pragma DATA_SEG DEFAULT

It is all in the manual.
0 件の賞賛
返信

2,262件の閲覧回数
CrasyCat
Specialist III
Hello
 
  Be careful that works for HC08 and HC12, but does not work that way for other architecture.
 
  This is one of the reason we always have to know which target CPU is used in CodeWarrior.
 
CrasyCat
0 件の賞賛
返信