Read-Only, I said!

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

Read-Only, I said!

930 次查看
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 回复数

577 次查看
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 项奖励
回复

577 次查看
WadeH
Contributor III

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

Wade Hassler

0 项奖励
回复

577 次查看
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 项奖励
回复

577 次查看
pgo
Senior Contributor V

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

bye

0 项奖励
回复