How to define an array of integers at a specific memory address?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to define an array of integers at a specific memory address?

579 Views
peterzheng
Contributor II

Hi,

 

Currently I am writing a program using CodeWarrior Bareboard project. I need to create an array of integers at a specific memory address in P4080DS.

 

For example. 0x12345678

 

I have tried pointer to array, but it seems not working. Is there a way I can do that?


Regards,

Peter

Labels (1)
0 Kudos
1 Reply

359 Views
lunminliang
NXP Employee
NXP Employee

Hi,

How about below reply:

How to define an array of integers at a specific memory address in P4080DS?

You may define an array pointer which points to the address directly, but this looks not safe. The address and array length should be available and legal, not used by other code or data, otherwise exception/unexpected behavior.

So consider the way of placing your array into a memory section you define. Something like:

#pragma push

#pragma section [ objecttype | permission ][iname][uname][data_mode=datamode][code_mode=codemode]

__declspec(section <section_name>) definition

#pragma pop

For usage, please refer to Power Arch Build Tools Reference.pdf in CodeWarrior installation folder C:\Freescale\CW_PA_v10.4.0\PA\Help\PDF

24.2.6 __declspec(section name)  and 36.3.2 section


Have a great day,
Lunmin

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos