Hi,
I want to place my function at absolute address in codewarrior10.3.
how to define function at Absolute Addresses in kL05Z32?
Solved! Go to Solution.
I suggest you use KEEP command in ld file. you can search this command in help manual for more information about it.
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).
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?
I suggest you use KEEP command in ld file. you can search this command in help manual for more information about it.
Hi, Jennie,
I found KEEP directive in IAR help. Thanks.
Allan
you are welcome