CMD使用举例
技术栈提前认知
1. 如何查看CCS中编译器版本?
概述
TI官方例程分析
1. 在CMD文件中进行配置
//判断当前编译器当前版本,上面有提到如何查看编译器版本
#if __TI_COMPILER_VERSION__ >= 15009000 #if defined(__TI_EABI__) //判断“输出格式”.TI.ramfunc : {} LOAD = FLASHD, //指定.TI.ramfunc加载存储区RUN = RAMLS0, //指定.TI.ramfunc运行存储区
//令编译器创建了一个变量RamfuncsLoadStart,该变量指向段.TI.ramfunc的装载地址的首地址LOAD_START(RamfuncsLoadStart),LOAD_SIZE(RamfuncsLoadSize),
//令编译器创建了一个变量RamfuncsLoadEnd,该变量指向段.TI.ramfunc的装载地址的末地址。LOAD_END(RamfuncsLoadEnd),RUN_START(RamfuncsRunStart),RUN_SIZE(RamfuncsRunSize),RUN_END(RamfuncsRunEnd),PAGE = 0, ALIGN(8)#else.TI.ramfunc : {} LOAD = FLASHD,RUN = RAMLS0,LOAD_START(_RamfuncsLoadStart),LOAD_SIZE(_RamfuncsLoadSize),LOAD_END(_RamfuncsLoadEnd),RUN_START(_RamfuncsRunStart),RUN_SIZE(_RamfuncsRunSize),RUN_END(_RamfuncsRunEnd),PAGE = 0, ALIGN(8)#endif#elseramfuncs : LOAD = FLASHD,RUN = RAMLS0,LOAD_START(_RamfuncsLoadStart),LOAD_SIZE(_RamfuncsLoadSize),LOAD_END(_RamfuncsLoadEnd),RUN_START(_RamfuncsRunStart),RUN_SIZE(_RamfuncsRunSize),RUN_END(_RamfuncsRunEnd),PAGE = 0, ALIGN(8)#endif
2. 程序中进行指定方法/变量的存储区块
#pragma CODE_SECTION(epwm1TZISR, ".TI.ramfunc");
在Memory Allocation中进行查看,可以发现FLASHD中新增了蓝色部分,在.TI.ramfunc区域。这就是编译器为epwm1TZISR方法分配的内存(右边可以看到时51个字节)
注意:在#pragma CODE_SECTION(epwm1TZISR, “.TI.ramfunc”);中的epwm1TZISR方法一定是要被调用的方法,要么在main.c中被调用,要么是中断函数。
3. 在程序初始化的时候进行内存拷贝
TI官方的例程一般都在 Device_init();方法中,如:
#ifdef _FLASH//// Copy time critical code and flash setup code to RAM. This includes the// following functions: InitFlash();//// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart symbols// are created by the linker. Refer to the device .cmd file.//memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
#endif
这样程序初始化的时候就会将RamfuncsLoadStart中的数据内容拷贝到RamfuncsRunStart中,拷贝的长度是RamfuncsLoadSize。
//LOAD = FLASHD
//RUN = RAMLS0
RamfuncsLoadStart =指的就是》FLASHD
RamfuncsRunStart=指的就是》RAMLS0