向量表文件 .sect ".vectors" .global _VECSTART .ref _c_int00 .def nmi, int0, int1, int2, int3, int4, int5, int6 .def int7, int8, int9, int10, int11, int12, int13 .def int14, int15, int16, int17, int18, int19, int20 .def int21, int22, int23, int24, int25, int26, int27 .def int28, int29 _VECSTART: .ivec _c_int00,c54x_stk nmi .ivec no_isr nop_16 int0 .ivec no_isr nop_16 int1 .ivec no_isr nop_16 int2 .ivec no_isr nop_16 int3 .ivec no_isr nop_16 int4 .ivec no_isr nop_16 int5 .ivec no_isr nop_16 int6 .ivec no_isr nop_16 int7 .ivec no_isr nop_16 int8 .ivec no_isr nop_16 int9 .ivec no_isr nop_16 int10 .ivec no_isr nop_16 int11 .ivec no_isr nop_16 int12 .ivec no_isr nop_16 int13 .ivec no_isr nop_16 int14 .ivec no_isr nop_16 int15 .ivec no_isr nop_16 int16 .ivec no_isr nop_16 int17 .ivec no_isr nop_16 int18 .ivec no_isr nop_16 int19 .ivec no_isr nop_16 int20 .ivec no_isr nop_16 int21 .ivec no_isr nop_16 int22 .ivec no_isr nop_16 int23 .ivec no_isr nop_16 int24 .ivec no_isr nop_16 int25 .ivec no_isr nop_16 int26 .ivec no_isr nop_16 int27 .ivec no_isr nop_16 int28 .ivec no_isr nop_16 int29 .ivec no_isr nop_16 .text .def no_isr no_isr: b #no_isr CMD文件 /**********************************************************/ /* */ /* LINKER command file for LEAD3 memory map */ /* */ /**********************************************************/ MEMORY { PAGE 0: MMR : origin = 0000000h, length = 00000c0h SPRAM : origin = 00000c0h, length = 0000040h VECS : origin = 0000100h, length = 0000100h DARAM0 : origin = 0000200h, length = 0003E00h DARAM1 : origin = 0004000h, length = 0004000h DARAM2 : origin = 0008000h, length = 0004000h DARAM3 : origin = 000c000h, length = 0004000h SARAM0 : origin = 0010000h, length = 0004000h SARAM1 : origin = 0014000h, length = 0008000h /* SARAM2 : origin = 0018000h, length = 0004000h */ SARAM3 : origin = 001c000h, length = 0004000h SARAM4 : origin = 0020000h, length = 0004000h SARAM5 : origin = 0024000h, length = 0004000h SARAM6 : origin = 0028000h, length = 0004000h SARAM7 : origin = 002c000h, length = 0004000h SARAM8 : origin = 0030000h, length = 0004000h SARAM9 : origin = 0034000h, length = 0004000h SARAM10 : origin = 0038000h, length = 0004000h SARAM11 : origin = 003c000h, length = 0004000h SARAM12 : origin = 0040000h, length = 0004000h SARAM13 : origin = 0044000h, length = 0004000h SARAM14 : origin = 0048000h, length = 0004000h SARAM15 : origin = 004c000h, length = 0004000h CE0 : origin = 0050000h, length = 03b0000h CE1 : origin = 0400000h, length = 0400000h CE2 : origin = 0800000h, length = 0400000h CE3 : origin = 0c00000h, length = 03f8000h PDROM : origin = 0ff8000h, length = 07f00h /* VECS : origin = 0ffff00h, length = 00100h*/ /* reset vector */ } SECTIONS { .vectors : {} > VECS PAGE 0 /* interrupt vector table */ .cinit : {} > SARAM0 PAGE 0 .text : {} > SARAM1 PAGE 0 .stack : {} > DARAM0 PAGE 0 .sysstack: {} > DARAM0 PAGE 0 .sysmem : {} > DARAM1 PAGE 0 .cio : {} > DARAM1 PAGE 0 .data : {} > DARAM1 PAGE 0 .bss : {} > DARAM1 PAGE 0 .const : {} > DARAM1 PAGE 0 .csldata : {} > DARAM0 PAGE 0 dmaMem : {} > DARAM0 PAGE 0 } 源程序 /* * Copyright 2003 by Texas Instruments Incorporated. * All rights reserved. Property of Texas Instruments Incorporated. * Restricted rights to use, duplicate or disclose this code are * granted through contract. * */ /* "@(#) DSP/BIOS 4.90.270 06-11-03 (barracuda-m10)" */ /******************************************************************************\ * Copyright (C) 2000 Texas Instruments Incorporated. * All Rights Reserved *------------------------------------------------------------------------------ * FILENAME...... timer.c * DATE CREATED.. 01/11/2000 * LAST MODIFIED. 01/04/2001 \******************************************************************************/ #include #include #include #include //#include /* This is a simple timer example to set the timer with */ /* an interrupt period of 0x400 cycles. */ /* The example uses predefined CSL macros and symbolic */ /* constants to create the correct register settings */ /* needed to configure the timer. */ /* Reference start of interrupt vector table */ /* This symbol is defined in file, vectors.s55 */ extern void VECSTART(void);// 中断向量表头声明 已在vectors.s55定义 #define TIMER_CTRL TIMER_TCR_RMK(\ TIMER_TCR_IDLEEN_DEFAULT, /* IDLEEN == 0 */ \ TIMER_TCR_FUNC_OF(0), /* FUNC == 0 */ \ TIMER_TCR_TLB_RESET, /* TLB == 1 */ \ TIMER_TCR_SOFT_BRKPTNOW, /* SOFT == 0 */ \ TIMER_TCR_FREE_WITHSOFT, /* FREE == 0 */ \ TIMER_TCR_PWID_OF(0), /* PWID == 0 */ \ TIMER_TCR_ARB_RESET, /* ARB == 1 */ \ TIMER_TCR_TSS_START, /* TSS == 0 */ \ TIMER_TCR_CP_PULSE, /* CP == 0 */ \ TIMER_TCR_POLAR_LOW, /* POLAR == 0 */ \ TIMER_TCR_DATOUT_0 /* DATOUT == 0 */ \ ) /* Create a TIMER configuration structure that can be passed */ /* to TIMER_config CSL function for initialization of Timer */ /* control registers. */ TIMER_Config timCfg0 = { TIMER_CTRL, /* TCR0 */ 0x3400u, /* PRD0 */ 0x0000 /* PRSC */ }; Uint16 eventId0; // 定义中断号,中间变量 /* Create a TIMER_Handle object for use with TIMER_open */ TIMER_Handle mhTimer0; //句柄 代表一个16位的数 存储一个地址 类似一个索引 代表一个对象的目录 桥梁 //int mhTimer0; //volatile Uint16 timer0_cnt = 0; //16位的地址变量 Uint16 timer0_cnt = 0; /* Function/ISR prototypes */ interrupt void int1(void); //void taskFxn(void); int old_intm; Uint16 tim_val; Uint16 xfchange = 0; void main(void) { /* Initialize CSL library - This is REQUIRED !!! */ /*CLS库的初始化,这是必需的*/ CSL_init(); /* Set IVPH/IVPD to start of interrupt vector table */ /*修改寄存器IVPH,IVPD,重新定义中断向量表*/ IRQ_setVecs((Uint32)(&VECSTART)); /* Temporarily disable all maskable interrupts */ /*禁止所有可屏蔽的中断源*/ old_intm = IRQ_globalDisable(); /* Open Timer 0, set registers to power on defaults */ /*打开定时器0,设置其为上电的的默认值,并返回其句柄*/ mhTimer0 = TIMER_open(TIMER_DEV0, TIMER_OPEN_RESET); /* Get Event Id associated with Timer 0, for use with */ /* CSL interrupt enable functions. */ /*获取定时器0的中断ID号*/ eventId0 = TIMER_getEventId(mhTimer0); /* Clear any pending Timer interrupts */ /*清除定时器0的中断状态位*/ IRQ_clear(eventId0); /* Place interrupt service routine address at */ /* associated vector location */ /*为定时器0设置中断服务程序*/ IRQ_plug(eventId0,&int1); /* Write configuration structure values to Timer control regs */ /*设置定时器0的控制与周期寄存器*/ TIMER_config(mhTimer0, &timCfg0); /* Enable Timer interrupt */ /*使能定时器的中断*/ IRQ_enable(eventId0); /* Enable all maskable interrupts */ /*设置寄存器ST1的INTM位,使能所有的中断*/ IRQ_globalEnable(); /* Start Timer */ /*启动定时器0*/ TIMER_start(mhTimer0); for(;;) { /* Wait for at least 10 timer periods */ /*等待10个定时周期*/ if(xfchange == 0) { /*点亮XF的LED*/ CHIP_FSET(ST1_55,XF,1); } else { /*关掉XF的LED*/ CHIP_FSET(ST1_55,XF,0); } } /* Restore old value of INTM */ /*恢复INTM旧的值*/ IRQ_globalRestore(old_intm); /* We are through with timer, so close it */ /*关掉定时器0*/ TIMER_close(mhTimer0); } /*定时器0的中断程序*/ interrupt void int1(void) { ++timer0_cnt; if(timer0_cnt == 3000) { xfchange = 1; } if(timer0_cnt == 6000) { timer0_cnt = 0; xfchange = 0; } }