How to set a specific variable address

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a specific variable address

1,892 Views
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
Labels (1)
0 Kudos
6 Replies

76 Views
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 Kudos

76 Views
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 Kudos

76 Views
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 Kudos

76 Views
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 Kudos

76 Views
Teckna
Contributor V

Is there any other suggestion?

 

Teckna

0 Kudos

76 Views
konrada
Contributor IV

You could go the

 

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

 

way. 

0 Kudos