How to set a specific variable address

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

How to set a specific variable address

3,585 次查看
Olivier
Contributor I
Hi everybody,
 
Does anyone know how to set up a variable at a specific address in CodeWarrior?
 
I need this to share a variable between two independent softwares (a bootloader and an application) in the RAM of a coldfire.
 
Thx,
Olivier
标签 (1)
0 项奖励
回复
6 回复数

1,769 次查看
CrasyCat
Specialist III

Hello

Which processor are you targeting (HC08, HC12, Coldfire, MPC82xx, ...)?

Which version of CodeWarrior are you using? To retrieve that info:

  - Start IDE
  - Select Help -> "About Freescale CodeWarrior"
  - Click on "Installed products"

The version number I am interested in are displayed on the top of the dialog.

CrasyCat

0 项奖励
回复

1,769 次查看
Teckna
Contributor V

I have the same need as Olivier, I use a custom board with K60N512 processor, Codewarrior 10.2 and MQX 3.8.

 

Many thanks

Teckna

0 项奖励
回复

1,769 次查看
konrada
Contributor IV

You can modify your linker script (.lcf file) and use __declspec in your code to place variables there.

 

See e.g. https://community.freescale.com/message/97982#97982 

 

The linker script language is also described in the CW build tools user guide, reachable from online help. 

0 项奖励
回复

1,769 次查看
Teckna
Contributor V

I'd not want to create a section for every variable I want to place at specific address: I've read about the syntax:

int var @ 0x60000000 = 5;

 (where 0x60000000 is the address where I want to place the var variable)

 

but it don't seem to be valid for the Kinetis architecture. Is there any similar syntax valid for the Kinetis architecture?

 

Many thanks

Teckna

0 项奖励
回复

1,769 次查看
Teckna
Contributor V

Is there any other suggestion?

 

Teckna

0 项奖励
回复

1,769 次查看
konrada
Contributor IV

You could go the

 

#define bla (*((unsigned long volatile*)0x12345678))

 

way. 

0 项奖励
回复