/*BootROM中的定点数值表,与语句 IQmath : > RAML1, PAGE = 0
IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD {
IQmath.lib
}
一起,是TI给出的使用28x IQmath Library提供的函数时程序中应该有的语句*/
FPUTABLES : origin = 0x3FEBDC, length = 0x0006A0 /*BootROM中的FPU数值表,与语句
FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
一起,是TI给出的使用 Fast RTS Library提供的函数时程序中应该有的语句*/
BOOTROM : origin = 0x3FF27C, length = 0x000D44
/*BootROM一部分,被保留*/
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 被用作BootROM的堆栈区 */
RAMM1 : origin = 0x000400, length = 0x000400
/* on-chip RAM block M1 片内SARAM M1区,被用作数据空间 */
RAML4 : origin = 0x00C000, length = 0x001000 /*片内SARAM L4区,被用作数据空间*/
RAML5 : origin = 0x00D000, length = 0x001000 /*片内SARAM L5区,被用作数据空间*/
RAML6 : origin = 0x00E000, length = 0x001000 /*片内SARAM L6区,被用作数据空间*/
RAML7 : origin = 0x00F000, length = 0x001000 /*片内SARAM L7区,被用作数据空间*/
ZONE7B : origin = 0x20FC00, length = 0x000400 /* XINTF zone 7 - data space
片外存储空间从0x20 FC00起1K的存储空间,定义为数据存储空间*/
}
/*将段分配到存储空间*/ SECTIONS {
/* Setup for \
The codestart section (found in DSP28_CodeStartBranch.asm) re-directs execution to the start of user code. */ codestart : > BEGIN, PAGE = 0
/*codestart段,跳转到rts2800.lib库的引导程序函数
_c_int00,该段放一跳转指令,指向 _c_int00函数的入口地址*/
ramfuncs : > RAML0, PAGE = 0
/*对应#pragma CODE_SECTION(InitFlash, \,
InitFlash函数必须在RAM中执行,因此给次函数分配一定的RAM空间 */
.text : > RAML1, PAGE = 0
/* 程序代码段(已初始化),放入片内SARAM L1区*/
.cinit : > RAML0, PAGE = 0
/* 全局与静态变量的初始值段(已初始化), 该段须放在低64K空间,放入片内SARAM L0区*/
.pinit : > RAML0, PAGE = 0
/*全局构造函数表,C++里面的constructor(已初始化),放入
片内SARAM L0区*/
.switch : > RAML0, PAGE = 0
/* switch表达式的表格段(已初始化),放入片内SARAM L0区
*/
.stack : > RAMM1, PAGE = 1
/* 堆栈空间段(未初始化),放入片内SARAM M1区*/
.ebss : > RAML4, PAGE = 1
/* 全局与静态变量段(未初始化),放入片内SARAM L4区*/
.econst : > RAML5, PAGE = 1
/* 常数(已初始化),放入片内SARAM L5区*/
.esysmem : > RAMM1, PAGE = 1
/* Farmalloc函数的存储空间(未初始化),放入片内SARAM M1
区*/
IQmath : > RAML1, PAGE = 0
IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
/*
IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD {
IQmath.lib
} */
FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
DMARAML4 : > RAML4, PAGE = 1 /*与DMA相连的空间 */ DMARAML5 : > RAML5, PAGE = 1 /*与DMA相连的空间 */ DMARAML6 : > RAML6, PAGE = 1 /* 与DMA相连的空间*/ DMARAML7 : > RAML7, PAGE = 1 /*与DMA相连的空间 */
ZONE7DATA : > ZONE7B, PAGE = 1 /* 外部数据存储空间*/
.reset : > RESET, PAGE = 0, TYPE = DSECT
/* not use */
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 }
下面对DSP2833x_Headers_nonBIOS.cmd文件的内容进行分析,BIOS是TI公司为DSP开发的实时操作系统,对于不使用BIOS的工程,用DSP2833x_Headers_nonBIOS.cmd文件对外设相关寄存器及PIE中断向量表进行配置。
adc_seq_ovd_test工程通过外设头文件、DSP2833x_GlobalVariableDefs.c文件、DSP2833x_Headers_nonBIOS.cmd文件这些文件,使我们在编程时可以方便的操作外设特殊功能寄存器对应的存储空间。
首先,在外设的头文件中,这里以DSP2833x_Adc.h文件为例来进行说明,按照F28335 DataSheet中定义的ADC相关寄存器的结构,用结构体、共用体变量的形式,定义了和各个ADC寄存器对应的变量。如对ADC控制寄存器1 ADCTRL1的定义: struct ADCTRL1_BITS { // bits description
Uint16 rsvd1:4; // 3:0 reserved
Uint16 SEQ_CASC:1; // 4 Cascaded sequencer mode Uint16 SEQ_OVRD:1; // 5 Sequencer override Uint16 CONT_RUN:1; // 6 Continuous run
Uint16 CPS:1; // 7 ADC core clock pre-scalar Uint16 ACQ_PS:4; // 11:8 Acquisition window size Uint16 SUSMOD:2; // 13:12 Emulation suspend mode Uint16 RESET:1; // 14 ADC reset Uint16 rsvd2:1; // 15 reserved };
union ADCTRL1_REG {
Uint16 all; struct ADCTRL1_BITS bit; };
然后再把与ADC相关的所有寄存器按照它们对应的存储空间的顺序定义为一个结构体变量:
struct ADC_REGS {
union ADCTRL1_REG ADCTRL1; // ADC Control 1 union ADCTRL2_REG ADCTRL2; // ADC Control 2 union ADCMAXCONV_REG ADCMAXCONV; // Max conversions
union ADCCHSELSEQ1_REG ADCCHSELSEQ1; // Channel select sequencing control 1
union ADCCHSELSEQ2_REG ADCCHSELSEQ2; // Channel select sequencing control 2
union ADCCHSELSEQ3_REG ADCCHSELSEQ3; // Channel select sequencing control 3
union ADCCHSELSEQ4_REG ADCCHSELSEQ4; // Channel select sequencing control 4
union ADCASEQSR_REG ADCASEQSR; // Autosequence status register
Uint16 ADCRESULT0; // Conversion Result Buffer 0 Uint16 ADCRESULT1; // Conversion Result Buffer 1 Uint16 ADCRESULT2; // Conversion Result Buffer 2 Uint16 ADCRESULT3; // Conversion Result Buffer 3 Uint16 ADCRESULT4; // Conversion Result Buffer 4 Uint16 ADCRESULT5; // Conversion Result Buffer 5 Uint16 ADCRESULT6; // Conversion Result Buffer 6 Uint16 ADCRESULT7; // Conversion Result Buffer 7 Uint16 ADCRESULT8; // Conversion Result Buffer 8 Uint16 ADCRESULT9; // Conversion Result Buffer 9 Uint16 ADCRESULT10; // Conversion Result Buffer 10 Uint16 ADCRESULT11; // Conversion Result Buffer 11
Uint16 ADCRESULT12; // Conversion Result Buffer 12 Uint16 ADCRESULT13; // Conversion Result Buffer 13 Uint16 ADCRESULT14; // Conversion Result Buffer 14 Uint16 ADCRESULT15; // Conversion Result Buffer 15 union ADCTRL3_REG ADCTRL3; // ADC Control 3
union ADCST_REG ADCST; // ADC Status Register Uint16 rsvd1; Uint16 rsvd2; union ADCREFSEL_REG ADCREFSEL; // Reference Select Register union ADCOFFTRIM_REG ADCOFFTRIM; // Offset Trim Register };
extern volatile struct ADC_REGS AdcRegs;
再在DSP2833x_GlobalVariableDefs.c文件中用#pragma指令将AdcRegs变量对应的存储空间定义为一个段AdcRegsFile。 #ifdef __cplusplus
#pragma DATA_SECTION(\#else
#pragma DATA_SECTION(AdcRegs,\#endif
volatile struct ADC_REGS AdcRegs;
在DSP2833x_Headers_nonBIOS.cmd文件中,首先用MEMORY命令将外设帧及PIE中断向量表对应的存储空间按DataSheet中提供的外设帧存储结构划分为各个存储空间,如: MEMORY {
PAGE 0: /* Program Memory */
PAGE 1: /* Data Memory */
ADC : origin = 0x007100, length = 0x000020 /* ADC registers */ }
然后用SECTION命令将在DSP2833x_GlobalVariableDefs.c文件中定义的段AdcRegsFile和MEMORY指令分配的为ADC寄存器分配的存储空间对应起来,如: SECTIONS {
AdcRegsFile : > ADC, PAGE = 1 }
DSP2833x_Headers_nonBIOS.cmd文件的作用就是按照DataSheet中提供的外设帧及PIE中断向量表的地址分配,用MEMORY命令将各个外设相关的所用寄存器对应的存储空间进行划分,然后用SECTIONS命令将在DSP2833x_GlobalVariableDefs.c文件中定义的各个和外设寄存器对应的段与MEMORY划分的存储空间联系起来。DSP2833x_Headers_nonBIOS.cmd文件的部分内容如下: