This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

tms20vc5416基于库函数编写的定时器中断程序有关于undefined first referenced 的错误



main code:

#include <stdio.h>
#include <csl.h>
#include <csl_irq.h>
#include <csl_timer.h>
#include <csl_chiphal.h>

/* 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);
extern void _timer_isr(void);


//#define TIMER_CTRL TIMER_TCR_RMK(\
// TIMER_TCR_SOFT_BRKPTNOW, /* SOFT == 0 */\
// TIMER_TCR_FREE_WITHSOFT, /* FREE == 0 */\
// TIMER_TCR_TRB_RESET, /* ARB == 1 */\
// TIMER_TCR_TSS_START, /* TSS == 0 */\
// TIMER_TCR_TDDR_OF(0)
//)


/* Create a TIMER configuration structure that can be passed */
/* to TIMER_config CSL function for initialization of Timer */
/* control registers. */
TIMER_Config timCfg0 = {
0x0669, /* TCR0 */
// 0x1000 , /* TSCR */
0x270f /* PRD */
};


Uint16 eventId0;

/* Create a TIMER_Handle object for use with TIMER_open */
TIMER_Handle mhTimer0;

volatile Uint16 timer0_cnt = 0;

/* Function/ISR prototypes */
interrupt void timer0Isr(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((Uint16)(&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,&timer0Isr);

/* 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*/
asm(" RSBX XF ");
}
else
{
/*关掉XF的LED*/
asm(" SSBX XF ");
}
}


/* 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 timer0Isr(void)
{
++timer0_cnt;
if(timer0_cnt == 500)
{
xfchange = 1;
}
if(timer0_cnt == 1000)
{
timer0_cnt = 0;
xfchange = 0;
}
}

构建中断向量程序(vector.asm)

*********************************************************************************
* Vector.ASM v1.00 *
* 版权(c) 2000- 北京合众达电子技术有限责任公司 *
* 设计者: 钱建良 *
*********************************************************************************
.file "memory.asm"
.c_mode
.mmregs

.ref _main
.ref _timer_isr
.def IV_RESET
.global _VECSTART

.sect ".vector"
_VECSTART:
IV_RESET: BD _main ; 复位中断,跳转到程序的入口
NOP
NOP
IV_NMI: RETE ; NMI中断,开中断返回
NOP
NOP
NOP
IV_SINT17: RETE ; 软件中断#17,开中断返回
NOP
NOP
NOP
IV_SINT18: RETE ; 软件中断#18,开中断返回
NOP
NOP
NOP
IV_SINT19: RETE ; 软件中断#19,开中断返回
NOP
NOP
NOP
IV_SINT20: RETE ; 软件中断#20,开中断返回
NOP
NOP
NOP
IV_SINT21: RETE ; 软件中断#21,开中断返回
NOP
NOP
NOP
IV_SINT22: RETE ; 软件中断#22,开中断返回
NOP
NOP
NOP
IV_SINT23: RETE ; 软件中断#23,开中断返回
NOP
NOP
NOP
IV_SINT24: RETE ; 软件中断#24,开中断返回
NOP
NOP
NOP
IV_SINT25: RETE ; 软件中断#25,开中断返回
NOP
NOP
NOP
IV_SINT26: RETE ; 软件中断#26,开中断返回
NOP
NOP
NOP
IV_SINT27: RETE ; 软件中断#27,开中断返回
NOP
NOP
NOP
IV_SINT28: RETE ; 软件中断#28,开中断返回
NOP
NOP
NOP
IV_SINT29: RETE ; 软件中断#29,开中断返回
NOP
NOP
NOP
IV_SINT30: RETE ; 软件中断#30,开中断返回
NOP
NOP
NOP
*********************************************************************************
* 本程序未用此中断 *
*********************************************************************************
IV_INT0: RETE
NOP
NOP
NOP
*********************************************************************************
* 本程序未用此中断 *
*********************************************************************************
IV_INT1: RETE
NOP
NOP
NOP
*********************************************************************************
* 外部中断#2:本系统未用 *
*********************************************************************************
IV_INT2: RETE
NOP
NOP
NOP
*********************************************************************************
* 内部定时中断#0:本系统未用 *
*********************************************************************************
IV_TINT0: BD _timer_isr
PSHM ST0
PSHM ST1
*********************************************************************************
* McBSP#0 接收中断:本系统未用 *
*********************************************************************************
IV_BRINT0:RETE
NOP
NOP
NOP
*********************************************************************************
* McBSP#0 发送中断:本系统未用 *
*********************************************************************************
IV_BXINT0:RETE
NOP
NOP
NOP
*********************************************************************************
* DMA通道#0 中断:本系统未用 *
*********************************************************************************
IV_DMAC0: RETE
NOP
NOP
NOP
*********************************************************************************
* 内部定时中断#1:本系统未用 *
*********************************************************************************
IV_TINT1: RETE
NOP
NOP
NOP
*********************************************************************************
* 外部中断#3:本系统未用 *
*********************************************************************************
IV_INT3: RETE
NOP
NOP
NOP
*********************************************************************************
* HPI中断:本系统未用 *
*********************************************************************************
IV_HPINT: RETE
NOP
NOP
NOP
*********************************************************************************
* McBSP#1 接收中断:本系统未用 *
*********************************************************************************
IV_BRINT1: RETE
NOP
NOP
NOP
*********************************************************************************
* McBSP#1 发送中断:本系统未用 *
*********************************************************************************
IV_BXINT1: RETE
NOP
NOP
NOP
*********************************************************************************
* DMA通道#4 中断:本系统未用 *
*********************************************************************************
IV_DMAC4: RETE
NOP
NOP
NOP
*********************************************************************************
* DMA通道#5 中断:本系统未用 *
*********************************************************************************
IV_DMAC5: RETE
NOP
NOP
NOP


.end

cmd file:

/**********************************************************/
/* */
/* 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
}

编译的结果:

warning: creating output section ".vector" without a SECTIONS specification

undefined first referenced
symbol in file
--------- ----------------
_timer_isr F:\\DSP5416_SourceCode\\timer\\Debug\\vector.obj

error: unresolved symbols remain
error: errors encountered during linking; "./Debug/timer0.out" not built

>> Compilation failure