首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

在8013的FLASH中如何存放数组

CodeWarrior7.x以上支持将常数或常数数组方在flash中.关键是在定义数组时要在定义的常量前加一个说明__pmem (两个下划线+pmem),另外link-command 文件也要修改,文件各是以 .cmd 结尾的。例如 sdm_pROM_xRAM.cmd.

__pmem const int sin_table[256]= {0,101,201,302,}
int X,Y;

void main(void)
{

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/

/* Write your code here */
Y = 5;
X=sin_table[Y];从flash中取一个数给到X

for(;;) {}
}

找到link_command 文件中以.ApplicationCode :开始,以>p_Code结尾的部分,加入2句

* (.const.data.pmem) # Comments
* (.const.data.char.pmem) # comments

下面是例子

.ApplicationCode :
{

F_Pcode_start_addr = .;

# .text sections
OBJECT (F_EntryPoint, Cpu.c) # The function _EntryPoint have to be placed at the beginning of the code
# section for proper functionality of the serial bootloader.
* (.text)
* (rtlib.text)
* (startup.text)
* (fp_engine.text)
* (user.text)
* (.const.data.pmem) # line is added by users
* (.const.data.char.pmem) # line is added by users

F_Pcode_end_addr = .;

# save address where for the data start in pROM
. = ALIGN(2);
__pROM_data_start = .;

} > .p_Code
你用了ProcessExpert.
你所要做的是到CPU bean里, Click "Build options" Button. 在这个介面的第8行将"Generate linker file" 设为"no"。sdm_pROM_xRAM.cmd.文件就不会再被改回原来的了。
返回列表