第二章CMD文件2.1、CMD文件综述CMD文件的主要作用是沟通物理存储器和逻辑地址的桥梁。
CMD文件反映了实际电路中存储单元的大小,并且通过阅读CMD文件可以得到系统中存储器的分配情况,特别是配合以MAP文件就可非常方便地得到系统资源的使用情况,有利于优化系统配置。
另外,由于C28X推荐使用C语言编程,就存在程序转化分段的问题,也在CMD中得到落实。
本实验系统采用的是瑞泰的CMD程序,并且是针对一个实验系统的通用CMD文件。
2.2、例解CMD文件1、寄存器区// 片上外设寄存器结构体与存储器分配的对应关系MEMORY //反映存储器空间范围、描述系统实际的硬件资源{PAGE 0: //第0页:程序空间存储器PAGE 1: //第1页:地址空间存储器//芯片仿真设定用寄存器(始于0x0000880 长:0x000180)DEV_EMU : origin = 0x000880, length = 0x000180//中断向量表PIE_VECT : origin = 0x000D00, length = 0x000100//闪存寄存器组FLASH_REGS : origin = 0x000A80, length = 0x000060//保密位寄存器组CSM : origin = 0x000AE0, length = 0x000010// 外部扩展寄存器组XINTF : origin = 0x000B20, length = 0x000020//定时器0 寄存器组CPU_TIMER0 : origin = 0x000C00, length = 0x000008//PIE控制寄存器组PIE_CTRL : origin = 0x000CE0, length = 0x000020 ///增强型CAN模块寄存器组ECANA : origin = 0x006000, length = 0x000040ECANA_LAM : origin = 0x006040, length = 0x000040ECANA_MOTS : origin = 0x006080, length = 0x000040 ECANA_MOTO : origin = 0x0060C0, length = 0x000040ECANA_MBOX : origin = 0x006100, length = 0x000100//系统控制寄存器组SYSTEM : origin = 0x007010, length = 0x000020//外设接口寄存器组SPIA : origin = 0x007040, length = 0x000010//异步串行通信接口寄存器组SCIA : origin = 0x007050, length = 0x000010//外部中断设定寄存器组XINTRUPT : origin = 0x007070, length = 0x000010//多功复用引脚选择寄存器组GPIOMUX : origin = 0x0070C0, length = 0x000020//多功能引脚数据寄存器组GPIODAT : origin = 0x0070E0, length = 0x000020//模拟数字转换寄存器组ADC : origin = 0x007100, length = 0x000020// 事件管理寄存器组EV A : origin = 0x007400, length = 0x000040EVB : origin = 0x007500, length = 0x000040//异步串行通信接口B寄存器组SCIB : origin = 0x007750, length = 0x000010//多通道缓冲接口寄存器组MCBSPA : origin = 0x007800, length = 0x000040//密码保护寄存器组CSM_PWL : origin = 0x3F7FF8, length = 0x000008}SECTIONS //建立与程序一一对应的关系、描述段是如何定位{PieVectTableFile : > PIE_VECT, PAGE = 1/*** Peripheral Frame 0 Register Structures ***///在头文件中可以找到DevEmuRegsFile的定义DevEmuRegsFile : > DEV_EMU, PAGE = 1FlashRegsFile : > FLASH_REGS, PAGE = 1CsmRegsFile : > CSM, PAGE = 1XintfRegsFile : > XINTF, PAGE = 1CpuTimer0RegsFile : > CPU_TIMER0, PAGE = 1PieCtrlRegsFile : > PIE_CTRL, PAGE = 1/*** Peripheral Frame 1 Register Structures ***/SysCtrlRegsFile : > SYSTEM, PAGE = 1SpiaRegsFile : > SPIA, PAGE = 1SciaRegsFile : > SCIA, PAGE = 1XIntruptRegsFile : > XINTRUPT, PAGE = 1GpioMuxRegsFile : > GPIOMUX, PAGE = 1GpioDataRegsFile : > GPIODAT PAGE = 1AdcRegsFile : > ADC, PAGE = 1EvaRegsFile : > EV A, PAGE = 1EvbRegsFile : > EVB, PAGE = 1ScibRegsFile : > SCIB, PAGE = 1McbspaRegsFile : > MCBSPA, PAGE = 1/*** Peripheral Frame 2 Register Structures ***/ECanaRegsFile : > ECANA, PAGE = 1ECanaLAMRegsFile : > ECANA_LAM PAGE = 1ECanaMboxesFile : > ECANA_MBOX PAGE = 1ECanaMOTSRegsFile : > ECANA_MOTS PAGE = 1ECanaMOTORegsFile : > ECANA_MOTO PAGE = 1/*** Code Security Module Register Structures ***/CsmPwlFile : > CSM_PWL, PAGE = 1}2、程序区/*// FILE: F2812_EzDSP_RAM_lnk.cmd//定位C程序在存储器中的位置-l rts2800.lib //链接库文件rts2800.lib-w //-stack 400h //栈大小为400h-heap 100 //堆大小为100MEMORY{PAGE 0 :///RAMM0 : origin = 0x000000, length = 0x000400//RAMM0 : origin = 0x3f6000, length = 0x001000BEGIN : origin = 0x3F8000, length = 0x000002/*BEGIN : origin = 0x3F7FF6, length = 0x000002*///PRAMH0 : origin = 0x3f8002, length = 0x001000PRAMH0 : origin = 0x81000, length = 0x002000RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */PAGE 1 :/* For this example, H0 is split between PAGE 0 and PAGE 1 */RAMM1 : origin = 0x000400, length = 0x000400DRAMH0 : origin = 0x3f8002, length = 0x001ffcDRAMH1 : origin = 0x83000, length = 0x004ffc}SECTIONS{codestart : > BEGIN, PAGE = 0//ramfuncs : > PRAMH0 PAGE = 0.text : > PRAMH0, PAGE = 0//文本段.cinit : > PRAMH0, PAGE = 0//.pinit : > PRAMH0, PAGE = 0.switch : > PRAMH0, PAGE = 0.reset : > RESET, PAGE = 0, TYPE = DSECT /* not used, */ .stack : > RAMM1, PAGE = 1.ebss : > DRAMH1, PAGE = 1.econst : > DRAMH0, PAGE = 1.esysmem : > DRAMH0, PAGE = 1.const : > DRAMH0, PAGE = 1.sysmem : > DRAMH0, PAGE = 1.cio : > DRAMH0, PAGE = 1}1..cinit 存放C程序中的变量初值和常量2..const 存放C程序中的字符常量、浮点常量和用const声明的常量3..text 存放C程序的代码4..bss 为C程序中的全局和静态变量保留存储空间5..far 为C程序中用far声明的全局和静态变量保留空间6..stack 为C程序系统堆栈保留存储空间,用于保存返回地址、函数间的参数传递、存储局部变量和保存中间结果7..sysmem用于C程序中malloc、calloc和realloc函数动态分配存配空间2.3文件类型.pjt CCS使用的工程文件.c C程序源文件.asm 汇编程序源文件.h 头文件.lib 库文件.cmd 连接命令文件.obj 目标文件.out 可执行文件.wks 工作区文件.dat 数据文件.map 映射文件2.4、常用命令。