how to define function at Absolute Addresses in kL05Z32?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how to define function at Absolute Addresses in kL05Z32?

跳至解决方案
2,230 次查看
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?

标签 (1)
标记 (3)
0 项奖励
回复
1 解答
1,841 次查看
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 项奖励
回复
5 回复数
1,841 次查看
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 项奖励
回复
1,841 次查看
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 项奖励
回复
1,842 次查看
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 项奖励
回复
1,841 次查看
kai_liu
Senior Contributor I

Hi, Jennie,

I found KEEP directive in IAR help. Thanks.

Allan

0 项奖励
回复
1,841 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

you are welcome

0 项奖励
回复