/*****************************************
Fucntion: test only for TMS320LF2407
Description: test only
Parameter: none
Author:liushunqiang@163.com
Date: oct 15th,2007
*****************************************/
1 主程序
/********************************************
File:main.c
Description: 主文件
********************************************/
#i nclude "../head/LF2407.h"
/*************************************************************************
NOTE:系统初始化
*************************************************************************/
void system_init()
{
asm (" SETC INTM ");
asm (" CLRC SXM ");
asm (" CLRC OVM ");
asm (" CLRC CNF ");
*SCSR1=0x06ff;
*WDCR=0x00e8;
*IFR=0xffff;
*IMR=0x0013;
asm (" CLRC INTM ");
}
/*************************************************************************
NOTE:io 初始化
*************************************************************************/
void io_init()
{
*MCRA=0x00c7;
*MCRB=0x00d4;
*MCRC=0x3000;
/*SCITXD,SCIRXD,XINT1,SPIIMO,SPICLK,CANTX,CANRX,TDIRB,PWM1,PWM2,CLKINB*/
*PADATDIR=0xc7ff;
*PBDATDIR=0xffff;
*PCDATDIR=0x00ff;
*PDDATDIR=0xffff;
*PEDATDIR=0xffff;
*PFDATDIR=0xffff;
}
void main()
{
system_init();
io_init();
while(1)
*PBDATDIR=0xff01;
}
interrupt void c_int1()
{}
interrupt void nothing()
{
return ;
}
2 头文件,寄存器定义
/**************************************************************
; File Name : LF2407regs.h
; Originator : Texas Instrument
; Description: LF2407 Peripheral Registers + other useful definitions
;**************************************************************/
/*--------------------------------------------------------------
; 片内外围寄存器定义
;--------------------------------------------------------------*/
/*C2xx 内核寄存器
;~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int *IMR = (volatile unsigned int *)0x0004;
/*中断屏蔽寄存器*/
volatile unsigned int *GREG = (volatile unsigned int *)0x0005;
/*全局变量定位寄存器*/
volatile unsigned int* IFR = (volatile unsigned int *) 0x0006;
/*中断标志寄存器*/
volatile unsigned int* ABRPT = (volatile unsigned int *) 0x01f;
/* 分析断点*/
ioport unsigned portFFFF;
#define WSGR portFFFF
/*系统模块寄存器
;~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * PIRQR0 = (volatile unsigned int *) 0x7010;
/* 外围中断请求寄存器0*/
volatile unsigned int * PIRQR1 = (volatile unsigned int *) 0x7011;
/* 外围中断请求寄存器1*/
volatile unsigned int * PIRQR2 = (volatile unsigned int *) 0x7012;
/* 外围中断请求寄存器2*/
volatile unsigned int * PIACKR0 = (volatile unsigned int *) 0x7014;
/* 外围中断应答寄存器0*/
volatile unsigned int * PIACKR1 = (volatile unsigned int *) 0x7015;
/* 外围中断应答寄存器1*/
volatile unsigned int * PIACKR2 = (volatile unsigned int *) 0x7016;
/* 外围中断应答寄存器2*/
volatile unsigned int * SCSR1 = (volatile unsigned int *) 0x7018;
/* 系统控制和状态寄存器1*/
volatile unsigned int * SCSR2 = (volatile unsigned int *) 0x7019;
/* 系统控制和状态寄存器2*/
volatile unsigned int * DIN = (volatile unsigned int *) 0x701C;
/*期间识别寄存器*/
volatile unsigned int * PVIR = (volatile unsigned int *) 0x701E;
/* 外围中断向量寄存器*/
/*看门狗/ 实时中断(RTI) / 锁相环 (PLL) 寄存器
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * WDCNTR = (volatile unsigned int *) 0x7023;
/*看门狗计数寄存器*/
volatile unsigned int * WDKEY = (volatile unsigned int *) 0x7025;
/* 看门狗 Key 寄存器*/
volatile unsigned int * WDCR = (volatile unsigned int *) 0x7029;
/* 看门狗控制寄存器*/
/*外围串行接口(SPI)寄存器
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * SPICCR = (volatile unsigned int *) 0x7040;
/* SPI配置控制寄存器1 */
volatile unsigned int * SPICTL = (volatile unsigned int *) 0x7041;
/* SPI 运行控制寄存器2 */
volatile unsigned int * SPISTS = (volatile unsigned int *) 0x7042;
/* SPI 状态寄存器 */
volatile unsigned int * SPIBRR = (volatile unsigned int *) 0x7044;
/* SPI 波特率控制寄存器 */
volatile unsigned int * SPIEMU = (volatile unsigned int *) 0x7046;
/* SPI 仿真缓冲寄存器 */
volatile unsigned int * SPIRXBUF = (volatile unsigned int *) 0x7047;
/* SPI 串行输入缓冲寄存器 */
volatile unsigned int * SPITXBUF = (volatile unsigned int *) 0x7048;
/* SPI 串行输出缓冲寄存器 */
volatile unsigned int * SPIDAT = (volatile unsigned int *) 0x7049;
/* SPI 串行数据寄存器 */
volatile unsigned int * SPIPC1 = (volatile unsigned int *) 0x704D;
/* SPI 端口控制寄存器1 */
volatile unsigned int * SPIPC2 = (volatile unsigned int *) 0x704E;
/* SPI端口控制寄存器2 */
volatile unsigned int * SPIPRI = (volatile unsigned int *) 0x7023;
/* SPI 优先级控制寄存器 */
/* 串行通信接口寄存器
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * SCICCR = (volatile unsigned int *) 0x7050;
/* SCI 通讯控制寄存器*/
volatile unsigned int * SCICTL1 = (volatile unsigned int *) 0x7051;
/* SCI 控制寄存器1*/
volatile unsigned int * SCIHBAUD = (volatile unsigned int *) 0x7052;
/* SCI 波特率控制寄存器高位*/
volatile unsigned int * SCILBAUD = (volatile unsigned int *) 0x7053;
/* SCI 波特率控制寄存器低位*/
volatile unsigned int * SCICTL2 = (volatile unsigned int *) 0x7054;
/* SCI 控制寄存器2*/
volatile unsigned int * SCIRXST = (volatile unsigned int *) 0x7055;
/* SCI 接收状态寄存器*/
volatile unsigned int * SCIRXEMU = (volatile unsigned int *) 0x7056;
/* SCI EMU 数据缓冲寄存器*/
volatile unsigned int * SCIRXBUF = (volatile unsigned int *) 0x7057;
/* SCI 接收数据缓冲寄存器 */
volatile unsigned int * SCITXBUF = (volatile unsigned int *) 0x7059;
/* SCI发送数据缓冲寄存器 */
volatile unsigned int * SCIPRI = (volatile unsigned int *) 0x705F;
/* SCI 优先级控制寄存器 */
/* 外围中断配置寄存器
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * XINT1CR = (volatile unsigned int *) 0x7070;
/* Int1 配置寄存器*/
volatile unsigned int * XINT2CR = (volatile unsigned int *) 0x7071;
/* Int2 配置寄存器*/
/* 数字 I/O 控制寄存器。
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * MCRA = (volatile unsigned int *) 0x7090;
/* I/O 复用控制寄存器A*/
volatile unsigned int * MCRB = (volatile unsigned int *) 0x7092;
/* I/O 复用控制寄存器B*/
volatile unsigned int * MCRC = (volatile unsigned int *) 0x7094;
/* I/O 复用控制寄存器C*/
volatile unsigned int * IPSRA = (volatile unsigned int *) 0x7094;
/*输入状态寄存器A*/
volatile unsigned int * IPSRB = (volatile unsigned int *) 0x7096;
/*输入状态寄存器B*/
volatile unsigned int * PADATDIR = (volatile unsigned int *) 0x7098;
/* I/O 端口 A 数据和方向控制寄存器*/
volatile unsigned int * PBDATDIR = (volatile unsigned int *) 0x709A;
/* I/O 端口 B 数据和方向控制寄存器*/
volatile unsigned int * PCDATDIR = (volatile unsigned int *) 0x709C;
/* I/O 端口 C 数据和方向控制寄存器*/
volatile unsigned int * PDDATDIR = (volatile unsigned int *) 0x709E;
/* I/O 端口 D 数据和方向控制寄存器*/
volatile unsigned int * PEDATDIR = (volatile unsigned int *) 0x7095;
/* I/O 端口 E 数据和方向控制寄存器*/
volatile unsigned int * PFDATDIR = (volatile unsigned int *) 0x7096;
/* I/O 端口 F 数据和方向控制寄存器*/
/*ADC 寄存器定义
;--------------------------------------------------------------*/
volatile unsigned int * ADCTRL1 = (volatile unsigned int *) 0x70A0;
/* ADC控制寄存器1*/
volatile unsigned int * ADCTRL2 = (volatile unsigned int *) 0x70A1;
/* ADC控制寄存器2*/
volatile unsigned int * MAXCONV = (volatile unsigned int *) 0x70A2;
/*最大转换通道寄存器*/
volatile unsigned int * CHSELSEQ1 = (volatile unsigned int *) 0x70A3;
/*通道选择域 :结果 3,2,1,0*/
volatile unsigned int * CHSELSEQ2 = (volatile unsigned int *) 0x70A4;
/*通道选择域 :结果 7,6,5,4*/
volatile unsigned int * CHSELSEQ3 = (volatile unsigned int *) 0x70A5;
/*通道选择域 :结果 11,10,9,8*/
volatile unsigned int * CHSELSEQ4 = (volatile unsigned int *) 0x70A6;
/*通道选择域 :结果 15,14,13,12*/
volatile unsigned int * AUTO_SEQ_SR = (volatile unsigned int *) 0x70A7;
/* 自动排序状态寄存器 */
volatile unsigned int * RESULT0 = (volatile unsigned int *) 0x70A8;
/* 转换结果寄存器 0*/
volatile unsigned int * RESULT1 = (volatile unsigned int *) 0x70A9;
/* 转换结果寄存器 1*/
volatile unsigned int * RESULT2 = (volatile unsigned int *) 0x70AA;
/* 转换结果寄存器 2*/
volatile unsigned int * RESULT3 = (volatile unsigned int *) 0x70AB;
/* 转换结果寄存器 3*/
volatile unsigned int * RESULT4 = (volatile unsigned int *) 0x70AC;
/* 转换结果寄存器 4*/
volatile unsigned int * RESULT5 = (volatile unsigned int *) 0x70AD;
/* 转换结果寄存器 5*/
volatile unsigned int * RESULT6 = (volatile unsigned int *) 0x70AE;
/* 转换结果寄存器 6*/
volatile unsigned int * RESULT7 = (volatile unsigned int *) 0x70AF;
/* 转换结果寄存器 7*/
volatile unsigned int * RESULT8 = (volatile unsigned int *) 0x70B0;
/* 转换结果寄存器 8*/
volatile unsigned int * RESULT9 = (volatile unsigned int *) 0x70B1;
/* 转换结果寄存器 9*/
volatile unsigned int * RESULT10 = (volatile unsigned int *) 0x70B2;
/* 转换结果寄存器 10*/
volatile unsigned int * RESULT11 = (volatile unsigned int *) 0x70B3;
/* 转换结果寄存器 11*/
volatile unsigned int * RESULT12 = (volatile unsigned int *) 0x70B4;
/* 转换结果寄存器 12*/
volatile unsigned int * RESULT13 = (volatile unsigned int *) 0x70B5;
/* 转换结果寄存器 13*/
volatile unsigned int * RESULT14 = (volatile unsigned int *) 0x70B6;
/* 转换结果寄存器 14*/
volatile unsigned int * RESULT15 = (volatile unsigned int *) 0x70B7;
/* 转换结果寄存器 15*/
volatile unsigned int * CALIBRATION = (volatile unsigned int *) 0x70B8;
/* 校准寄存器*/
/*局部控制网络(CAN) 寄存器
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * CANMDER = (volatile unsigned int *) 0x7100;
/* 邮包方向/使能寄存器*/
volatile unsigned int * CANTCR = (volatile unsigned int *) 0x7101;
/* 发送控制寄存器*/
volatile unsigned int * CANRCR = (volatile unsigned int *) 0x7102;
/* 接收控制寄存器*/
volatile unsigned int * CANMCR = (volatile unsigned int *) 0x7103;
/* 主动控制寄存器*/
volatile unsigned int * CANBCR2 = (volatile unsigned int *) 0x7104;
/* 位配置寄存器2*/
volatile unsigned int * CANBCR1 = (volatile unsigned int *) 0x7105;
/* 位配置寄存器1*/
volatile unsigned int * CANESR = (volatile unsigned int *) 0x7106;
/* 错误状态寄存器*/
volatile unsigned int * CANGSR = (volatile unsigned int *) 0x7107;
/* 全局状态寄存器 */
volatile unsigned int * CANCEC = (volatile unsigned int *) 0x7108;
/* CAN 错误计数寄存器*/
volatile unsigned int * CANIFR = (volatile unsigned int *) 0x7109;
/* CAN 中断标志寄存器*/
volatile unsigned int * CANIMR = (volatile unsigned int *) 0x710A;
/* CAN 中断屏蔽寄存器 */
volatile unsigned int * CANLAM0H = (volatile unsigned int *) 0x710B;
/* 局部接收屏蔽寄存器0 高位*/
volatile unsigned int * CANLAM0L = (volatile unsigned int *) 0x710C;
/* 局部接收屏蔽寄存器0 低位*/
volatile unsigned int * CANLAM1H = (volatile unsigned int *) 0x710D;
/* 局部接收屏蔽寄存器1 高位*/
volatile unsigned int * CANLAM1L = (volatile unsigned int *) 0x710E;
/* 局部接收屏蔽寄存器1 低位*/
volatile unsigned int * CANMSGID0L = (volatile unsigned int *) 0x7200;
/* 对于邮包0的信息标志符 低位 */
volatile unsigned int * CANMSGID0H = (volatile unsigned int *) 0x7201;
/* 对于邮包0的信息标志符 高位 */
volatile unsigned int * CANMSGCTRL0= (volatile unsigned int *) 0x7202;
/*对于邮包0的信息控制域*/
volatile unsigned int * CANMBX0A = (volatile unsigned int *) 0x7204;
/* 邮包0 A*/
volatile unsigned int * CANMBX0B =(volatile unsigned int *) 0x7205;
/* 邮包0 B*/
volatile unsigned int * CANMBX0C = (volatile unsigned int *) 0x7206;
/* 邮包 0 C*/
volatile unsigned int * CANMBX0D = (volatile unsigned int *) 0x7207;
/* 邮包 0 D*/
volatile unsigned int * CANMSGID1L = (volatile unsigned int *) 0x7208;
/* 对于邮包1的信息标志符 低位 */
volatile unsigned int * CANMSGID1H = (volatile unsigned int *) 0x7209;
/* 对于邮包1的信息标志符 高位 */
volatile unsigned int * CANMSGCTRL1= (volatile unsigned int *) 0x720A;
/*对于邮包1的信息控制域*/
volatile unsigned int * CANMBX1A = (volatile unsigned int *) 0x720C;
/*邮包 1 A*/
volatile unsigned int * CANMBX1B = (volatile unsigned int *) 0x720D;
/* 邮包 1 B*/
volatile unsigned int * CANMBX1C = (volatile unsigned int *) 0x720E;
/* 邮包 1 C*/
volatile unsigned int * CANMBX1D = (volatile unsigned int *) 0x720F;
/* 邮包 1 D*/
volatile unsigned int * CANMSGID2L = (volatile unsigned int *) 0x7210;
/* 对于邮包2的信息标志符 低位 */
volatile unsigned int * CANMSGID2H = (volatile unsigned int *) 0x7211;
/* 对于邮包2的信息标志符 高位 */
volatile unsigned int * CANMSGCTRL2 = (volatile unsigned int *) 0x7212;
/*对于邮包2的信息控制域*/
volatile unsigned int * CANMBX2A = (volatile unsigned int *) 0x7214;
/* 邮包 2 A*/
volatile unsigned int * CANMBX2B = (volatile unsigned int *) 0x7215;
/*邮包2 B*/
volatile unsigned int * CANMBX2C = (volatile unsigned int *) 0x7216;
/*邮包2 C*/
volatile unsigned int * CANMBX2D = (volatile unsigned int *) 0x7217;
/*邮包2 D*/
volatile unsigned int * CANMSGID3L = (volatile unsigned int *) 0x7218;
/* 对于邮包3的信息标志符 低位 */
volatile unsigned int * CANMSGID3H = (volatile unsigned int *) 0x7219;
/* 对于邮包3的信息标志符 高位 */
volatile unsigned int * CANMSGCTRL3 = (volatile unsigned int *) 0x721A;
/*对于邮包3的信息控制域*/
volatile unsigned int * CANMBX3A = (volatile unsigned int *) 0x721C;
/* 邮包 3 A*/
volatile unsigned int * CANMBX3B = (volatile unsigned int *) 0x721D;
/* 邮包 3 B*/
volatile unsigned int * CANMBX3C = (volatile unsigned int *) 0x721E;
/* 邮包 3 C*/
volatile unsigned int * CANMBX3D =(volatile unsigned int *) 0x721F;
/* 邮包 3 D*/
volatile unsigned int * CANMSGID4L = (volatile unsigned int *) 0x7220;
/* 对于邮包4的信息标志符 低位 */
volatile unsigned int * CANMSGID4H = (volatile unsigned int *) 0x7221;
/* 对于邮包4的信息标志符 高位 */
volatile unsigned int * CANMSGCTRL4= (volatile unsigned int *) 0x7222;
/*对于邮包4的信息控制域*/
volatile unsigned int * CANMBX4A = (volatile unsigned int *) 0x7224;
/* 邮包 4 A*/
volatile unsigned int * CANMBX4B = (volatile unsigned int *) 0x7225;
/* 邮包 4 B*/
volatile unsigned int * CANMBX4C = (volatile unsigned int *) 0x7226;
/* 邮包 4 C*/
volatile unsigned int * CANMBX4D = (volatile unsigned int *) 0x7227;
/* 邮包 4 D*/
volatile unsigned int * CANMSGID5L = (volatile unsigned int *) 0x7228;
/* 对于邮包5的信息标志符 低位 */
volatile unsigned int * CANMSGID5H = (volatile unsigned int *) 0x7229;
/* 对于邮包5的信息标志符 高位 */
volatile unsigned int * CANMSGCTRL5 = (volatile unsigned int *) 0x722A;
/*对于邮包5的信息控制域*/
volatile unsigned int * CANMBX5A = (volatile unsigned int *) 0x722C;
/* 邮包 5 A*/
volatile unsigned int * CANMBX5B = (volatile unsigned int *) 0x722D;
/* 邮包 5 B*/
volatile unsigned int * CANMBX5C = (volatile unsigned int *) 0x722E;
/* 邮包 5 C*/
volatile unsigned int * CANMBX5D = (volatile unsigned int *) 0x722F;
/*邮包5 D*/
/*事件管理器 (EV)/ 事件管理器 A (EVA) 寄存器
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * GPTCONA = (volatile unsigned int *) 0x7400;
/* 通用定时器控制寄存器*/
volatile unsigned int * T1CNT = (volatile unsigned int *) 0x7401;
/* T1 计数器*/
volatile unsigned int * T1CMP = (volatile unsigned int *) 0x7402;
/* T1 比较值寄存器*/
volatile unsigned int * T1PER = (volatile unsigned int *) 0x7403;
/* T1 周期寄存器*/
volatile unsigned int * T1CON = (volatile unsigned int *) 0x7404;
/* T1 控制寄存器*/
volatile unsigned int * T2CNT = (volatile unsigned int *) 0x7405;
/* T2 计数器*/
volatile unsigned int * T2CMP = (volatile unsigned int *) 0x7406;
/* T2 比较值寄存器*/
volatile unsigned int * T2PER = (volatile unsigned int *) 0x7407;
/* T2 周期寄存器*/
volatile unsigned int * T2CON = (volatile unsigned int *) 0x7408;
/* T2 控制寄存器*/
volatile unsigned int * COMCONA = (volatile unsigned int *) 0x7411;
/* 比较控制寄存器*/
volatile unsigned int * ACTRA = (volatile unsigned int *) 0x7413;
/* 比较输出动作控制寄存器*/
volatile unsigned int * DBTCONA = (volatile unsigned int *) 0x7415;
/* 死区控制寄存器*/
volatile unsigned int * CMPR1 = (volatile unsigned int *) 0x7417;
/* 比较值1*/
volatile unsigned int * CMPR2 = (volatile unsigned int *) 0x7418;
/* 比较值2*/
volatile unsigned int * CMPR3 = (volatile unsigned int *) 0x7419;
/* 比较值3*/
volatile unsigned int * CAPCONA = (volatile unsigned int *) 0x7420;
/* 捕捉控制寄存器*/
volatile unsigned int * CAPFIFOA = (volatile unsigned int *) 0x7422;
/* 捕捉 FIFO A 状态寄存器*/
volatile unsigned int * CAP1FIFO = (volatile unsigned int *) 0x7423;
/* 捕捉1 FIFO 顶部*/
volatile unsigned int * CAP2FIFO = (volatile unsigned int *) 0x7424;
/* 捕捉 2 FIFO 顶部*/
volatile unsigned int * CAP3FIFO = (volatile unsigned int *) 0x7425;
/* 捕捉 3 FIFO 顶部*/
volatile unsigned int * CAP1FBOT = (volatile unsigned int *) 0x7427;
/* 捕捉 1 FIFO 底部 */
volatile unsigned int * CAP2FBOT = (volatile unsigned int *) 0x7428;
/* 捕捉 2 FIFO 底部 */
volatile unsigned int * CAP3FBOT = (volatile unsigned int *) 0x7429;
/* 捕捉 2 FIFO 底部 */
volatile unsigned int * EVAIMRA = (volatile unsigned int *) 0x742C;
/* EVA 中断屏蔽寄存器 A*/
volatile unsigned int * EVAIMRB = (volatile unsigned int *) 0x742D;
/* EVA中断屏蔽寄存器 B*/
volatile unsigned int * EVAIMRC = (volatile unsigned int *) 0x742E;
/* EVA 中断屏蔽寄存器 C*/
volatile unsigned int * EVAIFRA = (volatile unsigned int *) 0x742F;
/* EVA中断标志寄存器 A*/
volatile unsigned int * EVAIFRB = (volatile unsigned int *) 0x7430;
/* EVA 中断标志寄存器 B*/
volatile unsigned int * EVAIFRC = (volatile unsigned int *) 0x7431;
/* EVA中断标志寄存器 C*/
/*事件管理器 B (EVB) 寄存器
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
volatile unsigned int * GPTCONB = (volatile unsigned int *) 0x7500;
/*通用定时器控制寄存器*/
volatile unsigned int * T3CNT = (volatile unsigned int *) 0x7501;
/* T3计数器*/
volatile unsigned int * T3CMP = (volatile unsigned int *) 0x7502;
/* T3比较值寄存器*/
volatile unsigned int * T3PER = (volatile unsigned int *) 0x7503;
/* T3周期寄存器*/
volatile unsigned int * T3CON = (volatile unsigned int *) 0x7504;
/* T3控制寄存器*/
volatile unsigned int * T4CNT = (volatile unsigned int *) 0x7505;
/* T4计数器*/
volatile unsigned int * T4CMP = (volatile unsigned int *) 0x7506;
/* T4比较值寄存器*/
volatile unsigned int * T4PER = (volatile unsigned int *) 0x7507;
/* T4周期寄存器*/
volatile unsigned int * T4CON = (volatile unsigned int *) 0x7508;
/* T4控制寄存器*/
volatile unsigned int * COMCONB = (volatile unsigned int *) 0x7511;
/*比较控制寄存器*/
volatile unsigned int * ACTRB = (volatile unsigned int *) 0x7513;
/*比较输出动作控制寄存器*/
volatile unsigned int * DBTCONB = (volatile unsigned int *) 0x7515;
/*死区控制寄存器*/
volatile unsigned int * CMPR4 = (volatile unsigned int *) 0x7517;
/*比较值4*/
volatile unsigned int * CMPR5 = (volatile unsigned int *) 0x7518;
/*比较值5*/
volatile unsigned int * CMPR6 = (volatile unsigned int *) 0x7519;
/*比较值6*/
volatile unsigned int * CAPCONB = (volatile unsigned int *) 0x7520;
/*捕捉控制寄存器*/
volatile unsigned int * CAPFIFOB = (volatile unsigned int *) 0x7522;
/* 捕捉FIFO A 状态寄存器*/
volatile unsigned int * CAP4FIFO = (volatile unsigned int *) 0x7523;
/* 捕捉 4 FIFO 顶部*/
volatile unsigned int * CAP5FIFO = (volatile unsigned int *) 0x7524;
/* 捕捉 5 FIFO 顶部*/
volatile unsigned int * CAP6FIFO = (volatile unsigned int *) 0x7525;
/* 捕捉 6 FIFO 顶部*/
volatile unsigned int * CAP4FBOT = (volatile unsigned int *) 0x7527;
/* 捕捉 4 FIFO 底部*/
volatile unsigned int * CAP5FBOT = (volatile unsigned int *) 0x7528;
/*捕捉 5 FIFO 底部*/
volatile unsigned int * CAP6FBOT = (volatile unsigned int *) 0x7529;
/*捕捉 6 FIFO底部*/
volatile unsigned int * EVBIMRA = (volatile unsigned int *) 0x752C;
/* EVB中断屏蔽寄存器A*/
volatile unsigned int * EVBIMRB = (volatile unsigned int *) 0x752D;
/* EVB 中断屏蔽寄存器B*/
volatile unsigned int * EVBIMRC = (volatile unsigned int *) 0x752E;
/* EVB 中断屏蔽寄存器 C*/
volatile unsigned int * EVBIFRA = (volatile unsigned int *) 0x752F;
/* EVB 中断标志寄存器 A*/
volatile unsigned int * EVBIFRB = (volatile unsigned int *) 0x7530;
/* EVB 中断标志寄存器 B*/
volatile unsigned int * EVBIFRC = (volatile unsigned int *) 0x7531;
/* EVB 中断标志寄存器 C*/
/*-----------------------------------------------------------------------------
;常量的定义
;-----------------------------------------------------------------------------
;数据空间
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define B2_SADDR 0x0060 /*块 B2 的开始地址*/
#define B2_EADDR 0x007F /*块 B2 的结束地址*/
#define B0_SADDR 0x0200 /*块 B0 的开始地址*/
#define B0_EADDR 0x02FF /*块 B0 的结束地址*/
#define B1_SADDR 0x0300 /*块 B1 的开始地址*/
#define B1_EADDR 0x03FF /*块 B1 的结束地址*/
#define SARAM 0x0800 /*SARAM 的开始地址(0800h-0FFFh)*/
#define EXTDATA 0x8000 /*外部的数据空间的开始地址*/
/*经常用到的数据页
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define DP_B2 0 /*页 0 数据空间*/
#define DP_B01 4 /*页 4 B0(200H/80H)*/
#define DP_B02 5 /*页 5 B0(280H/80H)*/
#define DP_B11 6 /*页 6 B1(300H/80H)*/
#define DP_B12 7 /*页 7 B1(380H/80H)*/
#define DP_SARAM1 16 /*页 16 SARAM(800H/80H)*/
#define DP_PF1 224 /*页1 外设帧文件 (7000h/80h)(0XE0)*/
#define DP_PF2 225 /*页 2 外设帧文件 (7080h/80h)(0XE1)*/
#define DP_PF3 226 /*页 3 外设帧文件 (7100h/80h)(0XE2)*/
#define DP_PF4 227 /*页 4外设帧文件(7180h/80h)(0XE3)*/
#define DP_PF5 228 /*页 5外设帧文件(7200h/80h)(0XE4)*/
#define DP_EVA 232 /*EVA 寄存器文件 (7400h/80h)(0XE8)*/
#define DP_EVB 234 /*EVB 寄存器文件 (7500h/80h)(0XEA)*/
#define DP_EXT1 256 /*外部存储器的第一块(8000H/80H)*/
/*位测试指令的位代码(BIT)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define BIT15 0 /*位代码 15*/
#define BIT14 1 /*位代码14*/
#define BIT13 2 /*位代码13*/
#define BIT12 3 /*位代码12*/
#define BIT11 4 /*位代码11*/
#define BIT10 5 /*位代码10*/
#define BIT9 6 /*位代码9*/
#define BIT8 7 /*位代码8*/
#define BIT7 8 /*位代码7*/
#define BIT6 9 /*位代码6*/
#define BIT5 10 /*位代码5*/
#define BIT4 11 /*位代码4*/
#define BIT3 12 /*位代码3*/
#define BIT2 13 /*位代码2*/
#define BIT1 14 /*位代码1*/
#define BIT0 15 /*位代码0*/
/*用SBIT0和SBIT1宏屏蔽位
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define B15_MSK 0x8000 /*位屏蔽15*/
#define B14_MSK 0x4000 /*位屏蔽14*/
#define B13_MSK 0x2000 /*位屏蔽13*/
#define B12_MSK 0x1000 /*位屏蔽12*/
#define B11_MSK 0x0800 /*位屏蔽11*/
#define B10_MSK 0x0400 /*位屏蔽10*/
#define B9_MSK 0x0200 /*位屏蔽9*/
#define B8_MSK 0x0100 /*位屏蔽8*/
#define B7_MSK 0x0080 /*位屏蔽7*/
#define B6_MSK 0x0040 /*位屏蔽6*/
#define B5_MSK 0x0020 /*位屏蔽5*/
#define B4_MSK 0x0010 /*位屏蔽4*/
#define B3_MSK 0x0008 /*位屏蔽3*/
#define B2_MSK 0x0004 /*位屏蔽2*/
#define B1_MSK 0x0002 /*位屏蔽1*/
#define B0_MSK 0x0001 /*位屏蔽0*/
/*看门狗定时器复位字符串
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define wd_rst_1 0x0055
#define wd_rst_2 0x00AA
/*以下为用户自行定义的变量
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
3 CMD文件,存储分配
/*************************************************************************
NOTE:TMS320LF2407 without external ram and rom
*************************************************************************/
MEMORY
{
PAGE 0: VECS: origin = 0x008000, length 0x0040
PAGE 0: PROG: origin = 0x008080, length 0x780
PAGE 1: B2 : origin = 0x000060, length 0x20
PAGE 1: B0 : origin = 0x000200, length 0x100
PAGE 1: B1 : origin = 0x000300, length 0x100
PAGE 1: DATA: origin = 0x000800, length 0x0700
}
SECTIONS
{
.vectors : {} >VECS PAGE 0 /* 中断向量表 */
.text : {} >PROG PAGE 0 /* 可执行代码和字符串 */
.cinit : {} >PROG PAGE 0 /* 初始化变量和常数表 */
.bss : {} >DATA PAGE 1 /* 保留全局变量和静态变量空间 */
.const : {} >DATA PAGE 1 /* 字符串和switch表 */
/*.switch : {} >DATA PAGE 1 /* 包含.switch语句建立的表格 */
.stack : {} >DATA PAGE 1 /* 为系统堆栈分配存储器 */
.system : {} >DATA PAGE 1 /*为动态存储器函数分配存储器空间 */
}
4 vectors.asm 中断向量文件
/********************************************
File:vectors.asm
Description:vectors.asm 中断向量文件
Author:liushunqiang@163.comNOV,22th,2005
********************************************/
.ref _c_int0;
.ref _nothing;
.sect ".vectors"
reset: B _c_int0 ;
int0: B _nothing ;
int2: B _nothing ;
int3: B _nothing ;
int4: B _nothing ;
int5: B _nothing ;
int6: B _nothing
其中的gel文件可选,为程序的清晰性