Reg: const variables in CW

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reg: const variables in CW

1,092 Views
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

 

Labels (1)
0 Kudos
6 Replies

705 Views
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 Kudos

705 Views
girichavana
Contributor II

Hi,

My target is HC08 MCU

Thanks

0 Kudos

705 Views
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

705 Views
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 Kudos

705 Views
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

705 Views
girichavana
Contributor II

Helly Catherine Bezy,

     Thanks for the useful information.

0 Kudos