TMS320F28335项目开发记录6_28335之cmd文件详解

1.CMD文件的作用

    CMD文件的作用就像仓库的货物摆放记录一样,为程序代码数据分配指定的空间。

2.C语言生成的段

    C语言生成的段大致分为两大类:初始化和未初始化,已初始化的段含有真正的指令和数据,未初始化段只是保留变量的地址空间。已初始化段通常放在程序空间,未初始化段通常放在数据空间。

已初始化段:

.text——C语言编译生成的汇编指令代码存放于此

.cinit——存放初始化的全局和静态变量

.const——字符串常量和const定义的全局和静态变量

.econst——字符串常量和far const定义的全局和静态变量

.print——全局构造器(C++)程序列表

.switch——存放switch语句产生的常数表格

以.const段为例:

const int a = 10;  //注意必须是全局的 如果声明为局部const初始化变量,不会放在.const段,局部变量都是运行时放在.bss段中
char * p = "ABC";
数组和结构体的初始值——是局部变量时,产生的是.const,如果是全局变量,产生的是.cinit

未初始化段:

.bss——为全局变量和局部变量保留的空间,程序上电时,.cinit空间中的数据复制出来并存放在.bss空间中

.ebss——为使用大寄存器模式时预留的全局和局部变量空间,程序上电时,.cinit空间中的数据复制出来并存放在.bss空间中

.stack——堆栈空间,主要用于函数传递变量或为局部变量分配空间

.system——为动态存储分配保留的空间(malloc),如果有宏函数,此空间被占用

.esystem——为动态存储分配保留的空间(far malloc),如果有far函数,此空间会被占用


3.自定义段

上面的都是官方预先定义好的,我们可以定义自己的段么?可以,使用如下语句:

#pragma CODE_SECTION(symbol, "section name");
#pragma DATA_SECTION(symbol, "section name");
symbol——符号,可以是函数名/变量名

section name——自定义的段名

CODE_SECTION用来定义代码段

DATA_SECTION用来定义数据段

注意

不能再函数体内声明#pragma;

必须在符号被定义和使用之前声明#pragma

例子:

#pragma DATA_SECTION(data, "data_name");
char data[100];


4.CMD文件

    在DSP28335工程文件里(不用BIOS产生CMD文件),手写CMD文件一般有两个,RAM里调试时用的两个CMD文件分别为DSP2833x_Headers_nonBIOS.cmd和28335_RAM_lnk.cmd,烧写flash里时用的两个CMD文件分别为DSP2833x_Headers_nonBIOS.cmd和F28335.cmd,其中DSP2833x_Headers_nonBIOS.cmd文件可以在所有工程文件中通用,主要作用是把外设寄存器产生的数据段映射到对应的存储空间,可以跟DSP2833x_GlobalVariableDefs.c文件对照一下看看。在我的上一篇文章中也有提到。

    其实我们也不需要详细的知道如何编写cmd文件,可以照着原有的修改就可以了。

    下面是官方28335_RAM_lnk.cmd,一般情况下直接用TI给的,不需要做修改即可满足调试用,模式较固定,当然你也可以做相应的修改用到哪块RAM存储空间,在CMD文件里做相应的分配即可

MEMORY
{
PAGE 0 :
   /* BEGIN is used for the "boot to SARAM" bootloader mode      */

   BEGIN      : origin = 0x000000, length = 0x000002     /* Boot to M0 will go here                      */
   RAMM0      : origin = 0x000050, length = 0x0003B0
   RAML0      : origin = 0x008000, length = 0x001000
   RAML1      : origin = 0x009000, length = 0x001000
   RAML2      : origin = 0x00A000, length = 0x001000
   RAML3      : origin = 0x00B000, length = 0x001000
   ZONE7A     : origin = 0x200000, length = 0x00FC00    /* XINTF zone 7 - program space */
   CSM_RSVD   : origin = 0x33FF80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */
   CSM_PWL    : origin = 0x33FFF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA            */
   ADC_CAL    : origin = 0x380080, length = 0x000009
   RESET      : origin = 0x3FFFC0, length = 0x000002
   IQTABLES   : origin = 0x3FE000, length = 0x000b50
   IQTABLES2  : origin = 0x3FEB50, length = 0x00008c
   FPUTABLES  : origin = 0x3FEBDC, length = 0x0006A0
   BOOTROM    : origin = 0x3FF27C, length = 0x000D44


PAGE 1 :
   /* BOOT_RSVD is used by the boot ROM for stack.               */
   /* This section is only reserved to keep the BOOT ROM from    */
   /* corrupting this area during the debug process              */

   BOOT_RSVD  : origin = 0x000002, length = 0x00004E     /* Part of M0, BOOT rom will use this for stack */
   RAMM1      : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
   RAML4      : origin = 0x00C000, length = 0x001000
   RAML5      : origin = 0x00D000, length = 0x001000
   RAML6      : origin = 0x00E000, length = 0x001000
   RAML7      : origin = 0x00F000, length = 0x001000
   ZONE7B     : origin = 0x20FC00, length = 0x000400     /* XINTF zone 7 - data space */
}

SECTIONS
{
   /* Setup for "boot to SARAM" mode:
      The codestart section (found in DSP28_CodeStartBranch.asm)
      re-directs execution to the start of user code.  */
   codestart        : > BEGIN,     PAGE = 0
   ramfuncs         : > RAML0,     PAGE = 0
   .text            : > RAML1,     PAGE = 0
   .cinit           : > RAML0,     PAGE = 0
   .pinit           : > RAML0,     PAGE = 0
   .switch          : > RAML0,     PAGE = 0

   .stack           : > RAMM1,     PAGE = 1
   .ebss            : > RAML4,     PAGE = 1
   .econst          : > RAML5,     PAGE = 1
   .esysmem         : > RAMM1,     PAGE = 1

   IQmath           : > RAML1,     PAGE = 0
   IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD

   /* Uncomment the section below if calling the IQNexp() or IQexp()
      functions from the IQMath.lib library in order to utilize the
      relevant IQ Math table in Boot ROM (This saves space and Boot ROM
      is 1 wait-state). If this section is not uncommented, IQmathTables2
      will be loaded into other memory (SARAM, Flash, etc.) and will take
      up space, but 0 wait-state is possible.
   */
   /*
   IQmathTables2    : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
   {

              IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)

   }
   */

   FPUmathTables    : > FPUTABLES, PAGE = 0, TYPE = NOLOAD

   DMARAML4         : > RAML4,     PAGE = 1
   DMARAML5         : > RAML5,     PAGE = 1
   DMARAML6         : > RAML6,     PAGE = 1
   DMARAML7         : > RAML7,     PAGE = 1

   ZONE7DATA        : > ZONE7B,    PAGE = 1

   .reset           : > RESET,     PAGE = 0, TYPE = DSECT /* not used                    */
   csm_rsvd         : > CSM_RSVD   PAGE = 0, TYPE = DSECT /* not used for SARAM examples */
   csmpasswds       : > CSM_PWL    PAGE = 0, TYPE = DSECT /* not used for SARAM examples */

   /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */
   .adc_cal     : load = ADC_CAL,   PAGE = 0, TYPE = NOLOAD

}

/*
//===========================================================================
// End of file.
//===========================================================================
*/


下面是官方F28335.cmd;

编写用于flash烧写的F28335.cmd文件时相对来说较复杂些,根据不同的情况需要做一些修改

1 不需要把部分代码copy到RAM里,一般情况不需要外扩RAM等时直接用TI的F28335.cmd即可。

2 需要把部分代码从flash 复制到RAM里,如延时函数DSP2833x_usDelay.asm等,这时CMD文件需要做相应的修改,具体参考博文:http://blog.sina.com.cn/s/blog_762cf5f80101asmq.html

3 从时间开销方面考虑,需要把整个程序从flash复制到RAM里,这时程序及CMD文件都要做相应的修改,具体参考博文http://blog.sina.com.cn/s/blog_762cf5f80101apfx.html

MEMORY
{
PAGE 0:    /* Program Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */

   ZONE0       : origin = 0x004000, length = 0x001000     /* XINTF zone 0 */
   RAML0       : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0 */
   RAML1       : origin = 0x009000, length = 0x001000     /* on-chip RAM block L1 */
   RAML2       : origin = 0x00A000, length = 0x001000     /* on-chip RAM block L2 */
   RAML3       : origin = 0x00B000, length = 0x001000     /* on-chip RAM block L3 */
   ZONE6       : origin = 0x0100000, length = 0x100000    /* XINTF zone 6 */ 
   ZONE7A      : origin = 0x0200000, length = 0x00FC00    /* XINTF zone 7 - program space */ 
   FLASHH      : origin = 0x300000, length = 0x008000     /* on-chip FLASH */
   FLASHG      : origin = 0x308000, length = 0x008000     /* on-chip FLASH */
   FLASHF      : origin = 0x310000, length = 0x008000     /* on-chip FLASH */
   FLASHE      : origin = 0x318000, length = 0x008000     /* on-chip FLASH */
   FLASHD      : origin = 0x320000, length = 0x008000     /* on-chip FLASH */
   FLASHC      : origin = 0x328000, length = 0x008000     /* on-chip FLASH */
   FLASHA      : origin = 0x338000, length = 0x007F80     /* on-chip FLASH */
   CSM_RSVD    : origin = 0x33FF80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */
   BEGIN       : origin = 0x33FFF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */
   CSM_PWL     : origin = 0x33FFF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */
   OTP         : origin = 0x380400, length = 0x000400     /* on-chip OTP */
   ADC_CAL     : origin = 0x380080, length = 0x000009     /* ADC_cal function in Reserved memory */
   
   IQTABLES    : origin = 0x3FE000, length = 0x000b50     /* IQ Math Tables in Boot ROM */
   IQTABLES2   : origin = 0x3FEB50, length = 0x00008c     /* IQ Math Tables in Boot ROM */  
   FPUTABLES   : origin = 0x3FEBDC, length = 0x0006A0     /* FPU Tables in Boot ROM */
   ROM         : origin = 0x3FF27C, length = 0x000D44     /* Boot ROM */        
   RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */
   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */

PAGE 1 :   /* Data Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
           /* Registers remain on PAGE1                                                  */
   
   BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */
   RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */
   RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
   RAML4       : origin = 0x00C000, length = 0x001000     /* on-chip RAM block L1 */
   RAML5       : origin = 0x00D000, length = 0x001000     /* on-chip RAM block L1 */
   RAML6       : origin = 0x00E000, length = 0x001000     /* on-chip RAM block L1 */
   RAML7       : origin = 0x00F000, length = 0x001000     /* on-chip RAM block L1 */
   ZONE7B      : origin = 0x20FC00, length = 0x000400     /* XINTF zone 7 - data space */
   FLASHB      : origin = 0x330000, length = 0x008000     /* on-chip FLASH */
}

/* Allocate sections to memory blocks.
   Note:
         codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code 
                   execution when booting to flash
         ramfuncs  user defined section to store functions that will be copied from Flash into RAM
*/ 
 
SECTIONS
{
 
   /* Allocate program areas: */
   .cinit              : > FLASHA      PAGE = 0
   .pinit              : > FLASHA,     PAGE = 0
   .text               : > FLASHA      PAGE = 0
   codestart           : > BEGIN       PAGE = 0
   ramfuncs            : LOAD = FLASHD, 
                         RUN = RAML0, 
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         PAGE = 0

   csmpasswds          : > CSM_PWL     PAGE = 0
   csm_rsvd            : > CSM_RSVD    PAGE = 0
   
   /* Allocate uninitalized data sections: */
   .stack              : > RAMM1       PAGE = 1
   .ebss               : > RAML4       PAGE = 1
   .esysmem            : > RAMM1       PAGE = 1

   /* Initalized sections go in Flash */
   /* For SDFlash to program these, they must be allocated to page 0 */
   .econst             : > FLASHA      PAGE = 0
   .switch             : > FLASHA      PAGE = 0      

   /* Allocate IQ math areas: */
   IQmath              : > FLASHC      PAGE = 0                  /* Math Code */
   IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD 
   
   /* Uncomment the section below if calling the IQNexp() or IQexp()
      functions from the IQMath.lib library in order to utilize the 
      relevant IQ Math table in Boot ROM (This saves space and Boot ROM 
      is 1 wait-state). If this section is not uncommented, IQmathTables2
      will be loaded into other memory (SARAM, Flash, etc.) and will take
      up space, but 0 wait-state is possible.
   */
   /*
   IQmathTables2    : > IQTABLES2, PAGE = 0, TYPE = NOLOAD 
   {
   
              IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)
   
   }
   */
   
   FPUmathTables    : > FPUTABLES, PAGE = 0, TYPE = NOLOAD 
         
   /* Allocate DMA-accessible RAM sections: */
   DMARAML4         : > RAML4,     PAGE = 1
   DMARAML5         : > RAML5,     PAGE = 1
   DMARAML6         : > RAML6,     PAGE = 1
   DMARAML7         : > RAML7,     PAGE = 1
   
   /* Allocate 0x400 of XINTF Zone 7 to storing data */
   ZONE7DATA        : > ZONE7B,    PAGE = 1

   /* .reset is a standard section used by the compiler.  It contains the */ 
   /* the address of the start of _c_int00 for C Code.   /*
   /* When using the boot ROM this section and the CPU vector */
   /* table is not needed.  Thus the default type is set here to  */
   /* DSECT  */ 
   .reset              : > RESET,      PAGE = 0, TYPE = DSECT
   vectors             : > VECTORS     PAGE = 0, TYPE = DSECT
   
   /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */
   .adc_cal     : load = ADC_CAL,   PAGE = 0, TYPE = NOLOAD

}

/*
//===========================================================================
// End of file.
//===========================================================================
*/

具体的工程实例,以后会给出;



  • 16
    点赞
  • 130
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: TMS320F28335是德州仪器公司(Texas Instruments)推出的一款高性能数字信号处理器(DSP)。它具有较强的计算能力和丰富的外设接口,广泛用于工业控制、电力电子、通信等领域的实时信号处理应用。 TMS320F28335全套开发例程是指一套完整的软件代码示例,旨在帮助开发人员快速上手并开发基于TMS320F28335的应用。这些例程通常包括以下几个方面: 1. 引导程序:通过引导程序,可以将用户的应用程序加载到DSP内部的闪存中,并实现启动和初始化功能。 2. 外设驱动程序:包括与TMS320F28335芯片内部外设相关的驱动程序,如模数转换器(ADC)、数模转换器(DAC)、通用串行总线(USB)、通用异步收发器(UART)等。这些驱动程序能够帮助开发人员快速使用和配置这些外设。 3. 信号处理算法:针对不同应用场景,提供了一些常见的信号处理算法的实现,如数字滤波、通信协议处理、图像处理等。开发人员可以根据自己的需求来选择和修改这些算法。 4. 联机调试工具:一些例程还提供了与开发板联机调试的工具,可以通过调试器和仿真器实时监测和修改DSP的运行状态,方便开发调试。 通过使用TMS320F28335全套开发例程,开发人员可以快速了解和掌握TMS320F28335开发环境和工具链,加快应用的开发速度,并且可以根据自己的需要进行二次开发和定制。这一套完整的开发例程为开发人员提供了一个良好的起点,使他们能够更好地利用TMS320F28335的强大功能,开发出高性能的实时信号处理应用。 ### 回答2: TMS320F28335是德州仪器(TI)公司推出的一款高性能的数字信号处理器(DSP)。它在工业控制、电力电子、电机驱动和汽车电子等领域广泛应用。为了帮助开发人员快速上手并加快开发过程,TI提供了TMS320F28335全套开发例程。 TMS320F28335全套开发例程包括了各种示例程序,涵盖了DSP的各个功能模块和特性。其中包括了基本的初学者示例,如LED灯闪烁、按键检测和串口通信等。这些简单的示例程序可以帮助开发者理解DSP的基本框架和编程方式。 此外,TMS320F28335全套开发例程还涵盖了更复杂和实用的应用场景。例如,ADC数据采集和处理、PWM波形生成和控制、PID算法实现以及通信协议(如CAN和SPI)的应用等。这些例程提供了具体的代码和详细的解释,帮助开发者理解和应用DSP的各种功能。 TI还提供了一些特定领域的开发例程,以满足特定应用需求。例如,电机驱动控制领域的例程,可以帮助工程师实现电机的速度和位置控制;电力电子领域的例程,可以帮助工程师理解和应用功率因数校正、谐波抑制等功能。 总之,TMS320F28335全套开发例程为开发者提供了丰富的资源和实践经验。通过学习和应用这些例程,工程师可以快速掌握DSP的编程和应用技巧,缩短开发周期,提高开发效率。同时,开发者还可以根据自己的应用需求进行修改和定制,以满足特定的应用场景。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值