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
|