Reg: const variables in CW

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

Reg: const variables in CW

2,546 次查看
girichavana
Contributor II

Greetings to all,

 

  I am working with CodeWarrior for MCU Version: 10. I need the clarification tha where the const variables will be stored ? is it in Flash memory (Code area) ?

 

If so, can i redirect these variables to store in RAM by using prm file ??

 

Thanks and Regards

 

标签 (1)
0 项奖励
回复
6 回复数

2,159 次查看
CrasyCat
Specialist III

Hello

  Which MCU are you targeting (HC08, Coldfire, Kinetis, ...)?

  Answer to this question depends on the target you are using.

CrasyCat

0 项奖励
回复

2,159 次查看
girichavana
Contributor II

Hi,

My target is HC08 MCU

Thanks

0 项奖励
回复

2,159 次查看
CrasyCat
Specialist III

Hello

HC08 compiler places all constants per default in a section called ROM_VAR (or .rodata).

This section is placed in flash in the.prm file generated by the wizard.

If you wish to get your constants allocated in RAM, just place the section into a RAM memory area in the .prm file PLACEMENT block.

If you have defined your own constant section (using pragma CONST_SEG), just place this section in a RAM memory area in the .prm file PLACEMENT block.

If you decide to allocate your constants in RAM, make sure you are not building with option -D__ONLY_INIT_SP. Initialization values for your constants will need to be copied from ROM to RAM at startup so you need to execute the whole startup code.

I hope this helps.

CrasyCat

2,159 次查看
girichavana
Contributor II

Hello,

Can you explain, where the option D__ONLY_INIT_SP will be available to enable/disable ?

Thanks&Regards

Giri Chavana

0 项奖励
回复

2,159 次查看
CrasyCat
Specialist III

Hello

  • Click right on the project name in the CodeWarrior Project view
  • Select Properties. The Project Properties dialog is opened.
  • Switch to C/C++ Build > Settings > Tool Settings > S08 Compiler > Preprocessor page.
  • If the symbol __ONLY_INIT_SP is listed in the list box, remove it.

CrasyCat

2,159 次查看
girichavana
Contributor II

Helly Catherine Bezy,

     Thanks for the useful information.

0 项奖励
回复