const in ROM?

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

const in ROM?

Jump to solution
815 Views
dougpaulsen
Contributor IV

This should really one of those entry level C programming questions, but in CW 6.3, I'm finding my expectations for the keyword "const" not to match CW's output.  The following declaration seems to be putting bmask into RAM (where #define UINT8 unsigned char):

 

     UINT8 const bmask[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };

 

I suppose so long as one has RAM to spare and CW initializes the array (not yet determined) I shouldn't really care.  Elsewhere, however, I've got some huge structures which would be an utter waste of resources to keep in RAM.

 

I've tried #pragma INTO_ROM.  I get a "Warning : illegal pragma" for my effort. 

 

Elsewhere, I've seen reverences to add -Cc to the linker command line.  I can't translate that into action using the IDE.

 

Are there tricks to get classic CW to store initialized arrays and structures in ROM?

 

Thanks!

doug

Labels (1)
0 Kudos
1 Solution
544 Views
dougpaulsen
Contributor IV

Well, it's me again.

Every have one of THOSE days at the office?

I found this response to my question posed by another party: <//community.freescale.com/message/113588#113588>  The answer there appears to be correct.  At least for the MCF51's, the "const" keyword works!  That is a name so declared (in my case, arrays and structures pre populated) is place in ROM.

What confused me is the IDE Link Order tab.  There, my const arrays show up in the "Data" column.  If, as the above discussion observes, you check under the debugger, the const array is actually in code space. The confusion is furthered by the fact that, despite optimizations being turned off for debugging, the compiler remains whizzy enough that it excludes unused variable so a lot of the stuff I'm trying to debug isn't included.

All of which is to say this whole exercise is something of a false alarm.  Sorry!

I think it's time to take a short break away from the keyboard and see if things might not improve after a short decompression reset.

View solution in original post

0 Kudos
2 Replies
544 Views
dougpaulsen
Contributor IV

Actually, using Google search rather than the Freescale forum search, if find this question has been asked before.  Unfortunately, those solutions seemed to focus on MC56xxxx projects.  I happen to be doing an MFC51 project right now.  The solutions I've found offered so far ( #pargma use_rodata, .data_in_xROM, Disable CONST variable by constant replacement, etc) don't seem to be available with an MCF51 project.  


I've done HSC08 projects.  There was a prn file where segments could be setup, but again this is different in MCF51 projects.

I'm kinda bummed at this point.  Closer inspection finds all that "const" stuff in RAM rather than ROM is chewing up RAM at a frightful pace.

0 Kudos
545 Views
dougpaulsen
Contributor IV

Well, it's me again.

Every have one of THOSE days at the office?

I found this response to my question posed by another party: <//community.freescale.com/message/113588#113588>  The answer there appears to be correct.  At least for the MCF51's, the "const" keyword works!  That is a name so declared (in my case, arrays and structures pre populated) is place in ROM.

What confused me is the IDE Link Order tab.  There, my const arrays show up in the "Data" column.  If, as the above discussion observes, you check under the debugger, the const array is actually in code space. The confusion is furthered by the fact that, despite optimizations being turned off for debugging, the compiler remains whizzy enough that it excludes unused variable so a lot of the stuff I'm trying to debug isn't included.

All of which is to say this whole exercise is something of a false alarm.  Sorry!

I think it's time to take a short break away from the keyboard and see if things might not improve after a short decompression reset.

0 Kudos