void main()
{
CSL_init();//CSL函数初始化
Htimer = TIMER_open(TIMER_DEV0,TIMER_OPEN_RESET);//打开定时器 0,返回定
时器句柄
TimerEventId = TIMER_getEventId(Htimer);//取得定时事件 ID
TIMER_config(Htimer,&Mtimer_configA);//配置定时器
Hgpio = GPIO_open(GPIO_DEV0,GPIO_OPEN_RESET);//打开 IO
GPIO_config(Hgpio,&Mgpio_config);//配置 IO
IRQ_setVecs(vectors);//重新设置中断向量,
IRQ_globalEnable();//全局中断使能
IRQ_nmiEnable();
IRQ_map(TimerEventId,14);//把定时中断重新映射到 14
IRQ_reset(TimerEventId);
IRQ_enable(TimerEventId);//
TIMER_start(Htimer);//定时开始
while(1);//死循环
TIMER_close(Htimer);
GPIO_close(Hgpio);
}
/**********************************************************************
* 中断服务程序
**********************************************************************/
interrupt void c_int14(void)//中断服务程序
{
if(flag==0)
{
GPIO_pinWrite(Hgpio,GPIO_PIN3,flag);
flag=1;
}
else
{
GPIO_pinWrite(Hgpio,GPIO_PIN3,1); //点灯
flag=0;
}
}
*------------------------------------------------------------------------------
* Global symbols defined here and exported out of this file
*------------------------------------------------------------------------------
.global _vectors//全局标号,可以在别处使用.
.global _c_int00
.global _vector1
.global _vector2
.global _vector3
.global _vector4
.global _vector5
.global _vector6
.global _vector7
.global _vector8
.global _vector9
.global _vector10
.global _vector11
.global _vector12
.global _vector13
.global _c_int14 ; Hookup the c_int14 ISR in main()
.global _vector15
*------------------------------------------------------------------------------
* Global symbols referenced in this file but defined somewhere else.
* Remember that your interrupt service routines need to be referenced here.
*------------------------------------------------------------------------------
.ref _c_int00//相当于 extern,在这里引用,在别处定义
*------------------------------------------------------------------------------
* This is a macro that instantiates one entry in the interrupt service table.
*------------------------------------------------------------------------------
VEC_ENTRY .macro addr//定义中断向量入口地址
STW B0,*--B15;保存B0 内容,中断产生后执行的第一条指令
MVKL addr,B0;
MVKH addr,B0;//把地址装入 B0
B B0;跳转至 B0 中存储的地址
LDW *B15++,B0;恢复B0内容; 由于C6000流水线的原因,跳转后仍然可以执行多条指
令
NOP 2
NOP
NOP
.endm
*------------------------------------------------------------------------------
* This is a dummy interrupt service routine used to initialize the IST.
*------------------------------------------------------------------------------
_vec_dummy:未定义中断服务程序
B B3;其他没有定义的中断跳转至 B3 存储的地址
NOP 5
*------------------------------------------------------------------------------
* This is the actual interrupt service table (IST). It is properly aligned and
* is located in the subsection .text:vecs. This means if you don't explicitly
* specify this section in your linker command file, it will default and link
* into the .text section. Remember to set the ISTP register to point to this
* table.
*------------------------------------------------------------------------------
.sect ".text:vecs";定义段
.align 1024;1024 字节对边界对齐
_vectors:
_vector0: VEC_ENTRY _c_int00 ;RESET 跳转到_c_int00 ,_c_int00是 c语言程序的入口
_vector1: VEC_ENTRY _vec_dummy ;NMI
_vector2: VEC_ENTRY _vec_dummy ;RSVD
_vector3: VEC_ENTRY _vec_dummy ; 所有未定义中断均跳转到同一地址
_vector4: VEC_ENTRY _vec_dummy
_vector5: VEC_ENTRY _vec_dummy
_vector6: VEC_ENTRY _vec_dummy
_vector7: VEC_ENTRY _vec_dummy
_vector8: VEC_ENTRY _vec_dummy
_vector9: VEC_ENTRY _vec_dummy
_vector10: VEC_ENTRY _vec_dummy
_vector11: VEC_ENTRY _vec_dummy
_vector12: VEC_ENTRY _vec_dummy
_vector13: VEC_ENTRY _vec_dummy
_vector14: VEC_ENTRY _c_int14 ; Hookup the c_int14 ISR in main() 定时中断中断向量
_vector15: VEC_ENTRY _vec_dummy
*------------------------------------------------------------------------------------------------------