how to define function at Absolute Addresses in kL05Z32?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to define function at Absolute Addresses in kL05Z32?

ソリューションへジャンプ
2,227件の閲覧回数
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,838件の閲覧回数
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,838件の閲覧回数
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,838件の閲覧回数
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,839件の閲覧回数
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,838件の閲覧回数
kai_liu
Senior Contributor I

Hi, Jennie,

I found KEEP directive in IAR help. Thanks.

Allan

0 件の賞賛
返信
1,838件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

you are welcome

0 件の賞賛
返信