一般来说,把一个在RAM里正常运行的程序移植到FLASH里(运行时将FLASH中的程序拷贝到RAM中运行)的步骤如下:
1.需要将适合RAM运行环境的CMD文件移出工程,替换成FLASH专用的的F28335.cmd
2.将另一个文件DSP2833x_CodeStartBranch.asm添加到工程中,如果工程内本来就有这个文件,就不用再添加了
3.在DSP28_SysCtrl.c文件中添加如下代码,如果工程里已有InitFlash函数,则不用再添加,检查下函数内容即可
1 #pragma CODE_SECTION(InitFlash, "RamFuncs"); 2 3 void InitFlash(void) 4 {
5 EALLOW; 6 //Enable Flash Pipeline mode to improve performance10 7 //of code executed from Flash. 8 FlashRegs.FOPT.bit.ENPIPE = 1; 9 10 //CAUTION11 //Minimum waitstates required for the flash operating12 //at a given CPU rate must be characterized by TI.13 //Refer to the datasheet for the latest information.14 //Set the Paged Waitstate for the Flash 15 FlashRegs.FBANKWAIT.bit.PAGEWAIT = 5;16 17 //Set the Random Waitstate for the Flash18 FlashRegs.FBANKWAIT.bit.RANDWAIT = 5;
19 //Set the Waitstate for the OTP
20 FlashRegs.FOTPWAIT.bit.OTPWAIT = 8;
21 //CAUTION
22 //ONLY THE DEFAULT VALUE FOR THESE 2 REGISTERS SHOULD BE USED23 FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF;
24 FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF;25 EDIS;26 //Force a pipe