DSP

F2812中程序从Flash中搬运到SRAM中运行加快速度

2019-07-13 16:45发布

参考文件:文档编号:spra958h.pdf------Running an Application from Internal Flash Memory on the TMS 320F28xxx DSP。   1、C语言函数搬运步骤: (1)cmd文件中定义相应的段:       ramfuncs                                : LOAD = FLASHC, PAGE = 0                                RUN = RAML0,   PAGE = 0                                RUN_START(_RamfuncsRunStart),                        LOAD_START(_RamfuncsLoadStart),                        LOAD_END(_RamfuncsLoadEnd) (2)声明变量: //InitFlash() extern unsigned int RamfuncsRunStart; extern unsigned int RamfuncsLoadStart; extern unsigned int RamfuncsLoadEnd; (3)将函数InitFlash()定位到定义的段ramfuncs中: #pragma CODE_SECTION(InitFlash, "ramfuncs"); (4)执行InitFlash()程序前将其从flash中搬运到sram中:              //将InitFlash()程序从Flash搬到RAM中运行        memcpy(&RamfuncsRunStart,&RamfuncsLoadStart,&RamfuncsLoadEnd - &RamfuncsLoadStart);        //初始化Flash        InitFlash(); 2、C语言调用的汇编函数搬运步骤: (1)cmd文件中定义相应的段:          .delayasmpage                            : LOAD = FLASHC, PAGE = 0                                  RUN = RAML0,   PAGE = 0                                  RUN_START(_DelayasmRunStart),                         LOAD_START(_DelayasmLoadStart),                         LOAD_END(_DelayasmLoadEnd) (2)声明变量: //Delay_asm() extern unsigned int DelayasmRunStart; extern unsigned int DelayasmLoadStart; extern unsigned int DelayasmLoadEnd; (3)将函数Delay_asm()定位到定义的段.delayasmpage中: .sect".delayasmpage" (4)执行Delay_asm()程序前将其从flash中搬运到sram中: //将Delay_asm()程序从Flash搬到RAM中运行               memcpy(&DelayasmRunStart,&DelayasmLoadStart,&DelayasmLoadEnd - &DelayasmLoadStart);               //延时1s               Delay_asm(18000000L);