assigning constant data into code space

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

assigning constant data into code space

2,233 次查看
stevec
Contributor III
I am porting an application over from the Keil C51 compiler. I am storing some constants in code space and the C51 code is

 void say(unsigned char word, unsigned char offset)
{
    unsigned long word_address;

    // word address high byte table
    code unsigned char addresstablehi[] = { 0x00,0x00,0x00,0x00,0x01,0x01,0x04,0x07 ,0x08 } ;
    .
    .
How do I perform this in CW.
The address table values are calculated by another program which produces a text file in the correct format so that I can cut and paste into the compiler, so I would hope the CW code would be similar.

Steve
标签 (1)
0 项奖励
回复
3 回复数

744 次查看
J2MEJediMaster
Specialist I
Doing I quick search on this forum, I found the following link which might get you started.

Also, it would probably help if you mentioned what version of CodeWarrior you're using and what MCU you're targeting.

---Tom

0 项奖励
回复

744 次查看
stevec
Contributor III
Thanks, I'm using CW 5.7 and using an MC9S08RE16.
0 项奖励
回复

744 次查看
CompilerGuru
NXP Employee
NXP Employee
Make your table static const.
For globals const alone is enough, but for locals you have to make them static (function static) too, otherwise CW will still allocate them on the stack.

Daniel

0 项奖励
回复