Save constants in xROM - How does it read back?

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

Save constants in xROM - How does it read back?

1,044 Views
Istvan
Contributor I
Hi all,

There is something I do not understand with the constants in CodeWarrior and the option "Save constants in xROM" from processor expert.
I have some big arrays that I want to save in the data flash memory of my DSP56F8346. So I have selected the option in Processor Expert. I have checked with the debugger, and my arrays are in the flash memory, where I want them to be. But it does not seem that the program is reading them. And I do not understand how it is suppose to read them back...
I could read them with a function "Read_From_Flash" from a bean with processor expert, but in that case, there is no reason to declare as constants as it will make the code much complicated... So if someone could explain me what is happening, or if I am suppose to do something to make the program uderstand that the constants arrays are in the data flash memory...
Thank you!
Labels (1)
0 Kudos
1 Reply

283 Views
Istvan
Contributor I
Oops... I have posted too fast actually... Just made a mistake in the code of my serial bootloader, but it is working fine.
Maybe I can explain quickly:
When the option "Save Constant In xROM" is selected, it means that any of the "const" variables will be stored in the data flash memory. So in the *.s file, there will be some lines for the data memory.
If you already use the data flash to store variables, you need to make sure that the constants will not overwrite your datas. To do so, I have cut the Data flash memory in two parts in the command file (*.cmd). Here is the tip:
1/ Find the lines:
        .x_internal_ROM  (RW)  : ORIGIN = 0x00001000, LENGTH = 0x1000
        .p_internal_RAM  (RWX) : ORIGIN = 0x0002F800, LENGTH = 0x0800

And change it to match your memory map. For example, my variables were stored in the dataflash from the address 0x00001000 to 0x000015FF, and then, it is free to add my constants. So I did:
        .x_internal_ROM  (RW)  : ORIGIN = 0x00001000, LENGTH = 0x600
        .x_const_in_ROM  (RW)  : ORIGIN = 0x00001600, LENGTH = 0xA00
        .p_internal_RAM  (RWX) : ORIGIN = 0x0002F800, LENGTH = 0x0800

2/ Now find the lines:
     .Data_xROM :
        {
              * (.const.data.char)  # used if "Emit Separate Char Data Section" enabled
              * (.const.data)

        } > .x_internal_ROM
3/ Replace ".x_internal_ROM" by your new location's name, for my example it becomes:
        .Data_xROM :
        {
              * (.const.data.char)  # used if "Emit Separate Char Data Section" enabled
              * (.const.data)

        } > .x_const_in_ROM
4/ And job done. All my constants will be stored in the data flash memory from 0x1600 to 0x1FFF.
0 Kudos