How to use “__attribute__” on MC9S12XEP100R chip?

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

How to use “__attribute__” on MC9S12XEP100R chip?

ソリューションへジャンプ
825件の閲覧回数
TingTing
Contributor II

Hi Developer,
I want to set a const value into plash with a const address. Then I met error as picture:
How to resolve it?
BR, Shi Ting Ting

TingTing_0-1609824144621.png

 

0 件の賞賛
1 解決策
822件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

CodeWarrior for HCS12(X) uses const to define global variable to FLASH. 

for example,

       const int VersionNbr = 2;

if define a const variable in a specific address, @is used, for example

    const unsigned int mycst_data@0xF08000=0xAAAA;

 

If these const variables are not used anywhere in the application, you have to instruct the Linker to avoid optimization.

This is done specifying the constant name in the .prm file ENTRIES block.

For example:

ENTRIES

  VersionNbr mycst_data

END

 

Please try it. If any issue, contact me again.

 

Have a nice day,

Jun Zhang

 

 

元の投稿で解決策を見る

0 件の賞賛
3 返答(返信)
823件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

CodeWarrior for HCS12(X) uses const to define global variable to FLASH. 

for example,

       const int VersionNbr = 2;

if define a const variable in a specific address, @is used, for example

    const unsigned int mycst_data@0xF08000=0xAAAA;

 

If these const variables are not used anywhere in the application, you have to instruct the Linker to avoid optimization.

This is done specifying the constant name in the .prm file ENTRIES block.

For example:

ENTRIES

  VersionNbr mycst_data

END

 

Please try it. If any issue, contact me again.

 

Have a nice day,

Jun Zhang

 

 

0 件の賞賛
808件の閲覧回数
TingTing
Contributor II

Hi Jun Zhang,

Thanks for your reply.

You mean use '@', but I cannot find '@' in your example.

I want to set a fixed value into fixed address in paged flash,for example,write 0x1234 into 0xFCBFF0.

How can I do?

Thank you so much.

BR, Shi Ting Ting

0 件の賞賛
805件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

I correct the example, please check it again.

Thanks,

Jun Zhang