Read-Only, I said!

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

Read-Only, I said!

1,753件の閲覧回数
WadeH
Contributor III

I have a program with the following two sets of data:

 

  // a list of ADDRESSES of BYTEs
#pragma INTO_ROM
  const  byte * These_Data[]={
&P12.b.high,          &P12.b.low,
&N12.b.high,          &N12.b.low,  
&HVDC.b.high,         &HVDC.b.low,
......
     };
#pragma INTO_ROM
// a list of LITERAL BYTEs
const byte These_Codes[] ={
P12_HB,         P12_LB,    
N12_HB,         N12_LB,  
HVDC_HB,        HVDC_LB,
......
     };

 The first is a list of addresses of data in SRAM... some words, some bytes, some longs, but all addressed as bytes

The second is a list of literal byte-values that will be sent along with the data found at the associated addresses.

No matter what I do, the LITERALS are compiled into ROM and the ADDRESSES end up in SRAM.

I'm not (yet) hurting for space, but it bugs me that data that is obviously (to me) invariant is always put in R/W memory.

What am I missing?

(9S12DX256, CW 5.90)

 

Thanks for any illumination

 

Wade Hassler

ラベル(1)
0 件の賞賛
返信
4 返答(返信)

1,400件の閲覧回数
kef
Specialist I

const  char * const  x;  // const pointer to const data

const  char *             x;  // nonconst pointer to const data

            char * const  x;  // const pointer to nonconst data

 

0 件の賞賛
返信

1,400件の閲覧回数
WadeH
Contributor III

Just so. Thank you for the help and the cheat-sheet

Wade Hassler

0 件の賞賛
返信

1,400件の閲覧回数
pgo
Senior Contributor V

Dear Wade,

 

Try adding a second const .  All you've done so far is say that the things pointed AT are constant - not the array itself.

 

 

#pragma INTO_ROM  const  byte * const These_Data[]={&P12.b.high,          &P12.b.low,&N12.b.high,          &N12.b.low,   &HVDC.b.high,         &HVDC.b.low,......     };

You didn't say what target but a similar example worked on CFV1 (Eclipse)

 

 bye

 

0 件の賞賛
返信

1,400件の閲覧回数
pgo
Senior Contributor V

Actually - you did say what chip - I just didn't read :smileyhappy:

bye

0 件の賞賛
返信