1、关于 TMS320F28XX 启动代码使用方法共 18 页链接 WARNNING 选项-w选项最好选上,有助于编译器在用户没有显式指定某一SECTION的链接方式时报warnning。The -w option can be selected in Code Composer Studio on the Project Build_Options menu, Linker tab, select the Advanced category, and then check the -w option box.内存大小端模式It is important that the large memory
2、 model be used with the C-compiler (as opposed to the small memory model). Small memory model requires certain initialized sections to be linked to non-volatile memory in the lower 64Kw of addressable space. However, no flash memory is present in this region on any current F28xx devices, and this wi
3、ll likely be true for future F28xx devices aswell. Therefore, large memory model should be used. In Code Composer Studio, the large memory model is on the Project Build_Options menu. Select the Compiler tab, choose the Advanced category, and check the -ml option box. For non-DSP/BIOS projects, one s
4、hould include the large memory model Ccompiler runtime support library, rts2800_ml.lib, into their code project (as opposed to rts2800.lib, which is for the small memory model). For DSP/BIOS projects, DSP/BIOS will take care of including the required library. The user should not include the rts2800_
5、ml.lib (or rts2800.lib) library into a DSP/BIOS project.Non-DSP/BIOSProjects 链接位置图表 1 LINKDSP/BIOS Projects 链接位置图表 2 LINKTable 2 Notes:1. The .trcdata section must be copied by the user from its load address (specified on theLoad_Address tab) to its run address (specified on the BIOS_Data tab) at ru
6、ntime. See Section4.3 for details on performing this copy.2. The PIEVECT RAM is a specific block of RAM associated with the Peripheral InterruptExpansion (PIE) peripheral. On current F28xx devices, the PIE RAM is a 256x16 block startingat address 0x000D00 in data space. For other devices, confirm th
7、e address in the devicedatasheet. The memory section manager in the DSP/BIOS configuration tool should alreadyhave a pre-defined memory named PIEVECT. The .hwi_vec section must be copied by the userfrom its load address (specified on the memory section manager Load_Address Tab) to its runaddress (sp
8、ecified on the memory section manager BIOS_Code Tab) at runtime. See Section4.2 for details on performing this copy.3. The specific flash memory selected as the load address for this section should be the sameflash memory selected previously as the run address for the section (e.g., on the BIOS_Data
9、,BIOS_Code, or Compiler_Sections tab).拷贝中断向量(non-DSP/BIOS only)调用 InitPieVectTable 函数完成中断向量拷贝,函数原型位于 DSP280x_PieVect.c。拷贝硬件向量(DSP/BIOS only)图表 3 拷贝中断向量拷贝.trcdata(DSP/BIOS only)第一步:需要如下图配置。图表 4 配置编译器第二步:代码实现。图表 5 拷贝 trcdata 代码实现FLASH 控制寄存器初始化 ( DSP/BIOS AND non-DSP/BIOS)图表 6 FLASH 控制器初始化CAUTION:The f
10、lash control registers are protected by the Code Security Module (CSM). If the CSM is secured, you must run the flash register initialization code from secured RAM (e.g., L0 or L1 SARAM) or the initialization code will be unable to access the flash registers. Note that the CSM is always secured at d
11、evice reset, although the ROM bootloader will unlock it if you are using dummy passwords of 0xFFFF.图表 7 secureRamFuncs定义图表 8 将代码从加载域拷贝到运行域拷贝到运行域提高速度(DSP/BIOS AND non-DSP/BIOS)The on-chip RAM memory on current F28xx devices provides code execution performance of 150 MIPS (millions of instructions per
12、 second) at 150 MHz on F281x devices, and 100 MIPS at 100 MHz on F280x devices. However, the on-chip flash memory on these devices provides effective code execution performance that is slightly less: roughly 90 100 MIPS on F281x devices, and roughly 85 90 MIPS on F280x devices.拷贝常量到运行域提高速度(DSP/BIOS
13、AND non-DSP/BIOS)方法一所有 const 变量的运行域都在 RAM,优点操作简单,缺点内存开销大。Non-DSP/BIOS Projects图表 9 常量运行域都在 RAM 的操作.econst 是系统标识符。DSP/BIOS Projects在这个模式下,虽然也可以单独指定.econst 的加载地址和运行地址,但是不会生成相应的可以被程序引用的符号,因此还是需要用户配置 link 文件指定。与Non-DSP/BIOS Projects相比较多出一个步骤,即需要指定用户 link文件先于系统link文件编译。通过Project Build_Options, selecting
14、the Link_Order tab,可以指定编译顺序,如下图所示。图表 10 指定用户的link文件优先于系统link文件.econst 是系统标识符。方法二(DSP/BIOS and non-DSP/BIOS projects)用户指定的部分常量,通过用户 link 文件分配到指定的 FLASH 加载,在指定的 RAM运行。这种方法的好处就是节省内存开销。利用DATA_SECTION关键字用户可以指定一个section,注意这个section不是.econst。将用户指定的常量的运行域指定到section。密码保护模式在开发阶段一般不需要密码保护,开发完成后为了方式嵌入式代码被非法拷贝,T
15、MS32028xx 提供了密码保护机制,就是所说的 CSM 模式。 TMS32028xx 的片内flash、OTP memory 以及 L0、L1 RAM 都是 CSM 保护的。当处于有密码保护的状态时,受CSM 保护的 RAM 之间可以互相访问,未受 CSM 保护的内存中的代码无法访问那些受CSM 保护的区域。CSM 使用 16 字节的密码锁,地址是 0x3F7FF8 至 0x3F7FFF。在开发阶段,最好通过擦除 FLASH 的方法将密码置为空(0xFFFF 就是空密码) 。开发完毕后,如果需要设置密码需要进行两步操作:1、往 0x3F7FF8 至 0x3F7FFF 写入密码(不可以全为
16、0,否则将永久锁定) ;2、将 0x3F7F80 至 0x3F7FF5 置为 0。Non-DSP/BIOS Projects写入密码方法:用汇编语言写个简单的文件 passwords.asm,用户替换 0xFFFF 为其它想要的密码。图表 11 汇编写 CSM 密码除了上述步骤外,还需要在用户 link 文件中指定“passwords”和“csm_rsvd”的地址,如下图所示:图表 12 用户 link 文件中配置地址DSP/BIOS Projects利用DSP/BIOS configuration tool定义内存地址,例如名称为PASSWORDS和CSM_RSVD。图表 13 汇编写密码图
17、表 14 用户link定义变量地址复位后从 FLASH 执行程序F28xx DSP具备bootloader,能在执行完bootloader 后跳转到FLASH执行,地址是0x3F7FF6。用户需要在该地址写入一条跳转指令,一般跳转到库函数执行C运行环境初始化函数_c_int00 。不过,用户可以根据实际需求跳转到汇编指令处,但需要记住不可以在调用_c_int00之前跳转到 C程序。DSP/BIOS和non-DSP/BIOS在操作上有所区别。non-DSP/BIOS图表 15 跳转指令DSP/BIOS禁止内部看门狗在 bootloader 后一般是跳转到 _c_int00 执行 C 环境初始化,其主要工作内容是将加载域中的变量值拷贝到运行域。这样在变量加大的情况下拷贝时间可能会比较长。而 DSP 复位后内部看门狗是默认开启的,因此有可能存在的一个问题是 C 环境尚未初始化之前看门狗起作用,导致无法正常进入 main 函数。一个简单的解决方法是在调用 C 环境初始化函数前将看门狗禁止掉,然后再 main 函数里面重新使能。这时候必须用到汇编语句,如下图所示:图表 16 禁止看门狗.