Assigning value to global variable in LCF is assigning an address instead of a value

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

Assigning value to global variable in LCF is assigning an address instead of a value

710 Views
j___
Contributor IV

Reading the "Linker Chapter" of "Targeting MC56F83xx/DSP5685x Controllers", page 286, it states that I can assign a value to global variable in the linker control file and then access it in the application C code. The variable must start with capital 'F'.

 

When I do this assignment, it is assigning an address to the variable rather than the value which is not helpful. In the "PDF manual" the example shows storing and retrieving a value, not address assignment and pointer operations. I actually wanted to use the F_var = .;. I got weird results to I resorted to using a constant, F_var = 0xAA55. This demonstrated the issue well.

 

See attachments.

I included a view of the X memory and P memory. In either case, it shows that a pointer out 0xAA54 is meaningless and non-nonsensical. Both are regions of all FF's.

 

If anyone can help or explain this to me, I would appreciate it.

 

Regards,

Jim

Original Attachment has been moved to: nxp_post_2016-02-18.txt.zip

Labels (1)
0 Kudos
1 Reply

375 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Jim

I viewed your link command file which defines “F__xRAM__start”  in LCF as:

        F__xRAM__start = 0xAA55;

By default, in C file, it uses the variable defined in LCF as an address, so in order to get your expected value in C file, please use it as below:

extern int __xRAM__start;

void function()

{

int i;

i = (int)&__xRAM__start;

}

I attached the example project, as well as the screenshot for its assembly out and running result.

var in lcf.png

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

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

-----------------------------------------------------------------------------------------------------------------------

0 Kudos