how to define function at Absolute Addresses in kL05Z32?

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

how to define function at Absolute Addresses in kL05Z32?

Jump to solution
1,163 Views
wangbaode
Contributor IV

Hi,

I want to place my function at absolute address in codewarrior10.3.

how to define function at Absolute Addresses in kL05Z32?

Labels (1)
0 Kudos
1 Solution
774 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

I suggest you use KEEP command in ld file. you can search this command in help manual for more information about it.

View solution in original post

0 Kudos
5 Replies
774 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

we need first specify a memory area to hold your variables/constants in Linker file .ld.

Then, in source code, use __attribute__ to place the variables/constants into this memory area.

I have created an example project for your reference.

Please note that memory section "my_section" is added in section MEMROY (line 26).

And in the follow, add placement .mydata (line53 ~ line58).

In main.c, place a const my_const into this memory area (line 9 of main.c).

0 Kudos
774 Views
kai_liu
Senior Contributor I

Will compiler play smart and optimize the unused variables and functions in absolute addresses?

For example, I design a ROM API in a memory area. The function seems an orphan in API development, how to prevent the compiler ignore them when building?

IAR? GCC?

0 Kudos
775 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

I suggest you use KEEP command in ld file. you can search this command in help manual for more information about it.

0 Kudos
774 Views
kai_liu
Senior Contributor I

Hi, Jennie,

I found KEEP directive in IAR help. Thanks.

Allan

0 Kudos
774 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

you are welcome

0 Kudos